tags:

views:

29

answers:

1

I have the following code where i save the xml file into this particular location shown below

public bool GetList(string keyword1, string streetname, string lat, string lng, string radius)
{

    XmlDocument xmlDoc=  CreateXML( keyword1,streetname,lat,lng,radius);
    xmlDoc.Save(@"C:\Documents and Settings\Vijay.EKO-03\Desktop\blockseek3-9-2010\Block3.xml");
     return true;

}

This Block3.xml file gets stored in my application folder, i refer to that particular Block3.xml using this code

function searchLocationsNear() 
{
    var searchUrl = "Block3.xml";
    GDownloadUrl(searchUrl, function(data) {
    var xml = GXml.parse(data);
    var markers = xml.documentElement.getElementsByTagName('marker');
    map.clearOverlays();

I am able to parse that Block3.xml and display results but my problem is during second iteration again when i try to save Block3.xml

xmlDoc.Save(@"C:\Documents and Settings\Desktop\blockseek3-9-2010\Block3.xml");

The previous Block3.xml file gets replaced by new one and gets stored in application folder when i execute var searchUrl="Block3.xml"; it reads the first Block3.xml not the replaced one ,can any one help to tackle this code . Is their any syntax to clear the saved xmldoc file in that particular folder .

+1  A: 

Most likely, the GXml class retains an open file handle. Check the documentation: if it implements IDisposable, wrap your processing code like this:

using ( var xml = GXml.parse(data) )
{
    var markers = xml.documentElement.getElementsByTagName('marker');
    map.clearOverlays();
}

This also assumes that the parse() method is the one that actually loads and reads the file. If you don't release the file handle, your process doesn't know that there's another version in the file system. (And other nasty stuff can happen, depending on the exact mode the O/S opened the file in.)

I trust your production code won't contain these hard coded paths...?

Pontus Gagge