locked
Modifying certain part of the HTML file from windows store app RRS feed

  • Question

  • Hi,

    I have a HTML file stored as a part of my application.

    I want to do a very simple modification to the content of the file.

    Below is my HTML code. Pls look at line 6. You see the following script..

     var myLatlng = new google.maps.LatLng(0,0);

    Based on some conditions, I want to the change (0,0) to (10.2,11.5) or to some other value. Can somebody help me how to perform this. This is the only part I need to modify to different values based on certain circumstances.

    <html>
         <head>
         <script src="</script">https://maps.googleapis.com/maps/api/js?sensor=false"></script>
         <script type="text/javascript">
             function load(){
                 var myLatlng = new google.maps.LatLng(0,0);
                 var mapOptions = {zoom: 15,center: myLatlng,mapTypeId: google.maps.MapTypeId.ROADMAP};
                 var map = new google.maps.Map(document.getElementById("map"), mapOptions);
                 var marker = new google.maps.Marker({,title:"Pole Location"});
                 marker.setMap(map);

                google.maps.event.addListener(map, 'click', function(event){placeMarker(event.latLng);});

                function placeMarker(location){
                     marker.setPosition(location);
                     document.getElementById("holder").innerHTML=location;
                 }
                
                 placeMarker(myLatlng);
             }
         </script>
         </head>
         <body onload="load()" style="margin:0px">
             <div id="map" style="width: 515px; height: 505px"></div>
             <div id="holder" ></div>
         </body>
     </html>

    Thursday, September 26, 2013 12:04 PM

Answers

  • Hi, Naveen

    I assume you put your html file in Document library, you can modify your html file by these steps:

    1. Read the file to a string

    2. Replace the contents

    3. Write back to the file.

    There are some codes you can refer to:

    StorageFolder storageFolder = KnownFolders.DocumentsLibrary;
                StorageFile sampleFile = await storageFolder.CreateFileAsync("tt.html", CreationCollisionOption.OpenIfExists);
                string fileContent = await FileIO.ReadTextAsync(sampleFile);
               fileContent=fileContent.Replace("var myLatlng = new google.maps.LatLng(0,0);", "var myLatlng = new google.maps.LatLng(0,2);");
                await FileIO.WriteTextAsync(sampleFile, fileContent);

    If you put your file in the Package Installed Location, you can read the file, but you do not have access to write or modify the file. You can refer to the link below to get more information:

    http://social.msdn.microsoft.com/Forums/en-US/e3e6dd3b-89b0-459d-acfe-86f91b5d311e/modifying-certain-part-of-the-html-file-from-windows-store-app

    Best Wishes!


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Anne Jing Monday, October 7, 2013 2:04 AM
    Friday, September 27, 2013 5:32 AM