Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need Help Reading an XML Document

Posted on 2006-07-13
2
Medium Priority
?
290 Views
Last Modified: 2010-05-18
I have this XML document and I need to read it, but I'm having trouble getting the nested information such as:

I want to read the <location> information into an array list for each Byte compare type ex ("office", "Quark")

<ByteCompareList>
    <ByteCompareType>
      <name>Office</name>
      <ByteCompareLocations>
        <Location>
          <at>43</at>
          <value>135</value>
        </Location>
        <Location>
          <at>44</at>
          <value>134</value>
        </Location>
        <returnFiletype>Access</returnFiletype>
      </ByteCompareLocations>
      <ByteCompareLocations>
        <Location>
          <at>32</at>
          <value>243</value>
        </Location>
        <Location>
          <at>33</at>
          <value>255</value>
        </Location>
        <returnFiletype>Word</returnFiletype>
      </ByteCompareLocations>
    </ByteCompareType>
    <ByteCompareType>
      <name>Quark</name>
      <ByteCompareLocations>
        <Location>
          <at>66</at>
          <value>143</value>
        </Location>
        <Location>
          <at>68</at>
          <value>98</value>
        </Location>
        <returnFiletype>Quark Template</returnFiletype>
      </ByteCompareLocations>
    </ByteCompareType>
  </ByteCompareList>

any help is greatly appreciated.

Thanks
0
Comment
Question by:asmyatt
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 17101328
This:

    XmlDocument doc = new XmlDocument();
    doc.Load("Your document.xml");

    XmlNodeList nodes = doc.SelectNodes("ByteCompareList/ByteCompareType/ByteCompareLocations/Location");

Will get you all of the Location nodes in the document. How you go about putting them into an ArrayList will depend on how you need to work with them.
0
 
LVL 11

Expert Comment

by:vo1d
ID: 17101768
why do you wanna read that data again in a different logical format?
xmldocument manages the data with an internal tree.
so you would get into memory problems if you have large xml files.
you can work with the xmlnodelist, which references every location nodes you need.

0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question