Solved

Need Help Reading an XML Document

Posted on 2006-07-13
2
239 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 500 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 Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now