473,395 Members | 1,987 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,395 software developers and data experts.

parsing xml files

How do I use XmlDocument class to parse an xml file such
as the following - note the key issue is the number of
<stuff> elements is not fixed so if I use m_nodelist =
m_xmld.SelectNodes("/start/level/stuff") to process the
nodes they all run together and I can't separate them by
the <level> that they are at because the number of times
they appear at each level is not fixed:

<start>
<level>
<stuff>
<firstthing>foo</firstthing>
<nextthing>boo</nextthing>
<stuff>
<stuff>
<firstthing>foo</firstthing>
<nextthing>boo</nextthing>
<stuff>
<level>
<level>
<stuff>
<firstthing>blue</firstthing>
<nextthing>goo</nextthing>
</stuff>
</level
</start>


Nov 20 '05 #1
2 986
Wade,
Have you considered using two loops/lists?

One loop/list to process Level, then a second nested loop/list to process
stuff?

m_layerList = m_xmld.SelectNodes("/start/level")

m_stuffList = m_layerList.SelectNodes("stuff")

Hope this helps
Jay

"Wade G" <wa************@chartermi.net> wrote in message
news:20*****************************@phx.gbl...
How do I use XmlDocument class to parse an xml file such
as the following - note the key issue is the number of
<stuff> elements is not fixed so if I use m_nodelist =
m_xmld.SelectNodes("/start/level/stuff") to process the
nodes they all run together and I can't separate them by
the <level> that they are at because the number of times
they appear at each level is not fixed:

<start>
<level>
<stuff>
<firstthing>foo</firstthing>
<nextthing>boo</nextthing>
<stuff>
<stuff>
<firstthing>foo</firstthing>
<nextthing>boo</nextthing>
<stuff>
<level>
<level>
<stuff>
<firstthing>blue</firstthing>
<nextthing>goo</nextthing>
</stuff>
</level
</start>


Nov 20 '05 #2
Yes, thanks. This is what I was trying to do but had the
syntax off slightly. I got it to work this morning -
note you need to use the node not the list to get the
inner node list. Here it is:

levellist = m_xmld.SelectNodes("/start/level")
For Each levelnode In levellist
stufflist = levelnode.SelectNodes("stuff")
For Each stuffnode In stufflist
'process the value
Next
Next

-----Original Message-----
Wade,
Have you considered using two loops/lists?

One loop/list to process Level, then a second nested loop/list to processstuff?

m_layerList = m_xmld.SelectNodes("/start/level")

m_stuffList = m_layerList.SelectNodes("stuff")

Hope this helps
Jay

"Wade G" <wa************@chartermi.net> wrote in message
news:20*****************************@phx.gbl...
How do I use XmlDocument class to parse an xml file such as the following - note the key issue is the number of
<stuff> elements is not fixed so if I use m_nodelist =
m_xmld.SelectNodes("/start/level/stuff") to process the
nodes they all run together and I can't separate them by the <level> that they are at because the number of times they appear at each level is not fixed:

<start>
<level>
<stuff>
<firstthing>foo</firstthing>
<nextthing>boo</nextthing>
<stuff>
<stuff>
<firstthing>foo</firstthing>
<nextthing>boo</nextthing>
<stuff>
<level>
<level>
<stuff>
<firstthing>blue</firstthing>
<nextthing>goo</nextthing>
</stuff>
</level
</start>


.

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
4
by: Marian Jancar | last post by:
Hi, Is there a module for parsing spec files available? Marian -- -- Best Regards,
0
by: rick_muller | last post by:
I'm interested in parsing a (simple) Makefile using Python. I need to write a packager for a program I'm supporting, and would like to read the list of files in the makefile so that I only have to...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
3
by: Girish | last post by:
Hi All, I have written a component(ATL COM) that wraps Xerces C++ parser. I am firing necessary events for each of the notifications that I have handled for the Content and Error handler. The...
9
by: PedroX | last post by:
Hello: I need to parse some large XML files, and save the data in an Access DB. I was using MSXML 2 and ASP, but it turns out to be extremely slow when then XML documents are like 10 mb in...
35
by: .:mmac:. | last post by:
I have a bunch of files (Playlist files for media player) and I am trying to create an automatically generated web page that includes the last 20 or 30 of these files. The files are created every...
1
by: Christoph Bisping | last post by:
Hello! Maybe someone is able to give me a little hint on this: I've written a vb.net app which is mainly an interpreter for specialized CAD/CAM files. These files mainly contain simple movement...
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
3
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.