Hi,
I have a small app that saves and loads data in XML format. Basically I have 2 methods. They each load data from a different XML documents. They both load data the same way. Everything works great except if I call method 1, then method 2, then method 1 again. When I call method 1 the second time, and the XmlDocument is loaded, it is missing a whole level of nodes. I put a break point on the XmlDocument right after the xmlDoc.Load() is called, and its not showing all the nodes that are in the document.
Method 2 is basically the same except it opens a different xml file. I can call method 1 many times and it works great. But once I call method 2, method 1 stops working. (The XmlNodeList "songs" above contains no nodes). "xmlDoc" only contains the first node. The actual file does not get altered. If I restart the app, Method 1 works correctly again, and loads all the nodes.
Any ideas?
Thanks
I have a small app that saves and loads data in XML format. Basically I have 2 methods. They each load data from a different XML documents. They both load data the same way. Everything works great except if I call method 1, then method 2, then method 1 again. When I call method 1 the second time, and the XmlDocument is loaded, it is missing a whole level of nodes. I put a break point on the XmlDocument right after the xmlDoc.Load() is called, and its not showing all the nodes that are in the document.
Code:
private void MethodOne()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("AllSongs.xml");
XmlNodeList songs = xmlDoc.SelectNodes("Songs/Song");
foreach (XmlNode node in songs)
{
// create Song object and add to ArrayList
}
//Display ArrayList of Songs
}
Any ideas?
Thanks
Comment