473,320 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem loading XML Document in C# .NET

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.

Expand|Select|Wrap|Line Numbers
  1. private void MethodOne()
  2. {
  3.    XmlDocument xmlDoc = new XmlDocument();
  4.    xmlDoc.Load("AllSongs.xml");
  5.    XmlNodeList songs = xmlDoc.SelectNodes("Songs/Song");
  6.    foreach (XmlNode node in songs)
  7.    {     
  8.       // create Song object and add to ArrayList             
  9.    }
  10.    //Display ArrayList of Songs
  11. }
  12.  
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
Feb 22 '08 #1
1 1253
Shashi Sadasivan
1,435 Expert 1GB
Could you paste some code on how you call the 2 methods?

Also check if the second xml file that you are talking abt is a valid xml file.
i.e with corect tags and an xml definition
Feb 22 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Shock | last post by:
Hello everyone, I am having a problem with the program below. I have isolated the problem to the onclick event that is located throughout arrQuestions. The onclick event refers to a function...
3
by: MN | last post by:
Hello all - I was hoping I could appeal to the gurus out there as I've researched this issue and can't seem to get this Flash movie to load at all. Below is my javascript code that I use to...
3
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These...
2
by: nick.taylor | last post by:
Hi, I've been trying for weeks to figure out this problem. I'm developing a simple Javascript app that loads an XML file from a server, parses the contents, and displays them. But I am...
2
by: darren | last post by:
I have a small Javascript problem with that mutch love web browser safari, I tested the code on all other browsers PC (Win) and Linux and IE on the mac and it seams to work ok, but for some reason...
2
by: billkirim | last post by:
i am using this code to preload my site: <script type="text/javascript"> document.write('<div id="loading"><br><br>The musicase is Loading...</div>'); window.onload=function(){ ...
1
by: agatha.life | last post by:
I did a javascript for the loading of images (I didn't want to have the images loaded in "on loading" because they are too many). The website is for a model and if you look at the codeof pages (...
2
by: jfaulky | last post by:
Hi all, I have a simply AJAX function that I pass a URL and it returns its contents to a <DIV id="mydivname"> area of my screen. All works fine when I manually enter:...
7
by: psybert | last post by:
Hello everyone, Long time lurker, first time poster. I'm a beginner coder, and I've taught myself everything with the help and expertise of users and websites like this one. I normally figure out...
6
by: Shigun | last post by:
On a website I am working on I am trying to load another page into a div on the the page the user does his work from. What I have works correctly in FireFox, but not in IE. I've rummaged Google for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.