473,396 Members | 2,010 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,396 software developers and data experts.

Parse XML into Collection - general use code?

I'm a newbie so please bear with me...

I'm looking to parse XML into a Collection so that I can pass that
collection around to functions to extract data from it easily.

I'm hoping there is code already to parse std XML files into a
Collection? All I've found is code where the XML structure is already
known... I need to code to work no matter what the structure... it
would "figure out" what nodes are parents/children and such then place
them into a Collection appropriately.

Any help is appreciated!
Nov 12 '05 #1
3 2167
An XmlDocument already defines a hierarchy of collections when it parses the
XML structure. A tree structure is created. You could use properties like
ChildNodes to enumerate the elements at a particular level.

This probably is not what you wanted so maybe you could provide more
information about the problem.

"Aaron" <al****@cox.net> wrote in message
news:85*************************@posting.google.co m...
I'm a newbie so please bear with me...

I'm looking to parse XML into a Collection so that I can pass that
collection around to functions to extract data from it easily.

I'm hoping there is code already to parse std XML files into a
Collection? All I've found is code where the XML structure is already
known... I need to code to work no matter what the structure... it
would "figure out" what nodes are parents/children and such then place
them into a Collection appropriately.

Any help is appreciated!

Nov 12 '05 #2
I'm looking for a simple way to parse std XML files into a vb.net
collection. Without needing to know what the data is or the header names
of what is in the file.
The parser would place the XML contents it into a collection and via the
structure of the collection, you'd know the hierarchy of the data.

thus wanting something like this...
<?xml version="1.0" encoding="UTF-8"?>
<collection>
<comment>Company employees</comment>
<section name="employee1">
<item key="name" value="Bob Johnson" />
<item key="department" value="Accounting" />
</section>
<section name="employee2">
<item key="name" value="Susan Fielding" />
<item key="department" value="Sales" />
</section>
</collection>

turn into a collection like this...

collection.comment.text = "Company employees"
collection.section.name = "employee1"
collection.section.name.employee1.item.name = "Bob Johnson"
collection.section.name.employee1.item.department = "Accounting"

... and so forth.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
Aaron Levey wrote:
collection.comment.text = "Company employees"
collection.section.name = "employee1"
collection.section.name.employee1.item.name = "Bob Johnson"
collection.section.name.employee1.item.department = "Accounting"

You cannot do it with *any* data, because above imply the structure of
data is known at development time. If the schema of your XML is known,
XML serialization is exactly what you are looking for.
For arbitrary XML - XPathDocument and XPath selections is the way to go,
if you need editing, then use XmlDocument.
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #4

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

Similar topics

2
by: Peter Kwan | last post by:
Hi, I believe I have discovered a bug in Python 2.3. Could anyone suggest a get around? When I tested my existing Python code with the newly released Python 2.3, I get the following warning: ...
1
by: Grandma Wilkerson | last post by:
Hi, The documentation states that enumeration through a collection is inherently NOT thread-safe, since a thread which added/removed an item from said collection could screw up the thread that...
6
by: Ganesh | last post by:
Is there a utility by microsoft (or anyone) to force garbage collection in a process without have access to the process code. regards Ganesh
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
2
by: S. Justin Gengo | last post by:
Hi, I've created a component that allows me to store database information for various types of databases my company uses. It uses a collection for each type of database. Everything is working...
1
by: Pi | last post by:
I'm looking at a piece of code that gets called over 100,000 times and was wondering if there would be much performance difference between these three scenarios or is there an alternate approach?:...
4
by: Michael | last post by:
Dear all .. If I want to use develop a user control and declare a public property which the type is System.Windows.Forms.GridTableStylesCollection For example : Public Class LookAndView...
3
by: jacob navia | last post by:
Abstract: Continuing the discussion about abstract data types, in this discussion group, a string collection data type is presented, patterned after the collection in C# and similar languages...
158
by: pushpakulkar | last post by:
Hi all, Is garbage collection possible in C++. It doesn't come as part of language support. Is there any specific reason for the same due to the way the language is designed. Or it is...
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: 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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.