[thelist] XML parsing
Michael Mell
mike at nthwave.net
Mon Oct 7 16:43:01 CDT 2002
I must have dropped a nut :-)
just to recap -
Option 1 is siblings all as children of the root element.
Option 2 is infinitely nested siblings. The younger brother nested inside the
elder.
Option 2 is more complicated to parse, will take longer and drain more memory.
Option 1 is the way xml is intended to be used.
Using Option 1 using Python minidom, you can gather all the topics in our
example with:
categoriesDom = xml.dom.minidom.parse('someFile.xml')
categoriesNodes = categoriesDom.documentElement.childNodes
for category in categoriesNodes:
if category.nodeType == xml.dom.minidom.Node.ELEMENT_NODE:
There is also the imminently handy getElementsByTagName(tagName)
m
Brian W King wrote:
> Personally speaking, I try to always follow Option 2 formatting. Some of
> the systems that I have to code around inherently interpret nested tags as
> parent and child, whereas I would have to set the receiving system up so
> that it understood option #1. Not all parsers are created with all of the
> compliance parsing information in them. If they are just simply importing
> data for a specific reason, why go through the expense of paying someone to
> code in all of the bells and whistles unless you needed them. I guess I am
> trying to say that I see simple parsers use option two inherently, more
> often than option 1.
>
> Brian
>
> -----Original Message-----
> From: thelist-admin at lists.evolt.org [mailto:thelist-admin at lists.evolt.org]On
> Behalf Of David.Cantrell at Gunter.AF.mil
> Sent: Monday, October 07, 2002 12:27 PM
> To: thelist at lists.evolt.org
> Subject: RE: [thelist] XML parsing
>
> >Option 2 seems to be logically incorrect -- each topic is not a subtopic
> >of the topic id=1.
>
> But when you create a topic with a parent attribute of parent=1 pointing to
> the topic with id=1, then you are creating a subtopic of id=1. You are just
> manually doing it instead of letting the XML parser handle it for you.
>
> -dave
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !
--
mike[at]nthwave.net
More information about the thelist
mailing list