Newbie to XML in Python

J

Jens Thiede

XML in Python doesn't seem easy or intuitive. All I need to do, is to
interpret a small piece of XML in which I store data for the contents of
an autorun menu. What is the quickest/most effective way to do this?

What should I use for this; SAX or DOM - and which parser of ether one,
or niether (if there is a third option)?

What are your views,

Jens.
 
J

Jeremy Jones

Jens said:
XML in Python doesn't seem easy or intuitive. All I need to do, is to
interpret a small piece of XML in which I store data for the contents
of an autorun menu. What is the quickest/most effective way to do this?

What should I use for this; SAX or DOM - and which parser of ether
one, or niether (if there is a third option)?

What are your views,

Jens.

depends.... I've had a lot of success parsing smallish XML files with
DOM. The thing I like about DOM is that you are the one walking through
the XML as you see fit by getting child nodes and attributes and blah
blah blah. With SAX (which I've not used much), you setup handlers, the
methods of which get called when tags are hit, which pretty much forces
you to setup a state machine to keep track of where you are in the
document. I looked into xpath, but wasn't able to quickly figure out
how to update attributes, but looked great just for querying an XML
file. I don't know the format of the autorun file you mentioned, but if
it's small and all you need to do is query it, you may want to expand
your sights to include xpath.


Jeremy
 
R

Richie Hindle

[Jens]
XML in Python doesn't seem easy or intuitive. All I need to do, is to
interpret a small piece of XML in which I store data for the contents of
an autorun menu. What is the quickest/most effective way to do this?

You're probably looking for an "XML data binding" rather than a SAX or DOM
implementation. I've had good results with XML_Objectify - see
http://www.xml.com/pub/a/2003/07/02/py-xml.html

Another option, which I've never used, is Anobind -
http://uche.ogbuji.net/tech/4Suite/anobind/

If your XML might not be well formed, Beautiful Soup is a good choice -
http://www.crummy.com/software/BeautifulSoup/
 
D

David Fraser

Jens said:
XML in Python doesn't seem easy or intuitive. All I need to do, is to
interpret a small piece of XML in which I store data for the contents of
an autorun menu. What is the quickest/most effective way to do this?

What should I use for this; SAX or DOM - and which parser of ether one,
or niether (if there is a third option)?

What are your views,

Jens.

Hi Jens

I use elementtree for this. If you want have a look at ooswitchlang in
the translate.sourceforge.net cvs - src/translate/tools directory :)

David
 
P

Peter Hansen

Jens said:
XML in Python doesn't seem easy or intuitive. All I need to do, is to
interpret a small piece of XML in which I store data for the contents of
an autorun menu. What is the quickest/most effective way to do this?

Quickest to run or quickest to write?

Most effective how?

The answer might, as answers often do, depend on the specific
characteristics of your "small piece of XML". I could easily
picture a tiny non-XML parser being considered the "quickest
and most effective" way for certain jobs...

-Peter
 
W

William Park

Jens Thiede said:
XML in Python doesn't seem easy or intuitive. All I need to do, is to
interpret a small piece of XML in which I store data for the contents of
an autorun menu. What is the quickest/most effective way to do this?

What should I use for this; SAX or DOM - and which parser of ether one,
or niether (if there is a third option)?

What are your views,

It depends on your data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top