Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need Help Reading an XML Document

Posted on 2006-07-13
2
Medium Priority
?
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

688 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