473,781 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2188
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.goog le.com...
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>Compan y employees</comment>
<section name="employee1 ">
<item key="name" value="Bob Johnson" />
<item key="department " value="Accounti ng" />
</section>
<section name="employee2 ">
<item key="name" value="Susan Fielding" />
<item key="department " value="Sales" />
</section>
</collection>

turn into a collection like this...

collection.comm ent.text = "Company employees"
collection.sect ion.name = "employee1"
collection.sect ion.name.employ ee1.item.name = "Bob Johnson"
collection.sect ion.name.employ ee1.item.depart ment = "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.comm ent.text = "Company employees"
collection.sect ion.name = "employee1"
collection.sect ion.name.employ ee1.item.name = "Bob Johnson"
collection.sect ion.name.employ ee1.item.depart ment = "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
4977
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: FutureWarning: hex/oct constants > sys.maxint will return positive values in Python 2.4 and up It is because I used some constants such as 0x80ff3366, so I change it to 0x80ff3366L, hoping to get rid of the warning.
1
2099
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 was iterating. That makes sense.. but... given a collection that is filled at start-time and never modified again, is it safe to have multiple threads *reading* (not writing to) the collection using foreach()? I have a class that exposes an...
6
810
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
3621
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 million lines. b) I need to store the contents into a unique hash. c) I need to then sort the data on a specific field. d) I need to pull out certain fields and report them to the user.
2
3309
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 perfectly except when the component is deleted from the page. Here are the details. I add the component to the page from the toolbox and then add items using the collection editor. I can delete those items from the collection using the collection...
1
1249
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?: == Scenario 1: == Dim colA as new Collection 'Collection of clsA objects <Add 10-20 clsA objects to colA collection>
4
2540
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 Inherits System.Windows.Forms.UserControl Private _Collection As GridTableStylesCollection
3
5092
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 (Java). It stores character strings, and resizes itself to accommodate new strings when needed. Interface: ----------
158
7906
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 discouraged due to some specific reason. If someone can give inputs on the same, it will be of great help. Regards, Pushpa
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10143
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10076
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2870
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.