xml question

J

JYOUNG79

Just curious if there's any python xml parsing tools built into the Mac (OS 10.4.10 Tiger)? If so,
could anyone
share some simple code (or maybe point me to a web-site) of how to parse xml data from a
file? For example, if I
had a file that contained this:

<colors>
<color base="DeviceGray" />
<color alt="DeviceCMYK" base="Separation">Black</color>
<color alt="Lab" base="Separation">Light Blue</color>
<color alt="ICCBased" base="Separation">Green</color>
</colors>

I'd want to look in the 'colors' xml element, then look at each 'color' xml element inside and
pull any that have
values (which would be Black, Light Blue and Green). I'd like to know how to pull 'attributes'
too.

Thanks very much for your help.

Jay
 
X

xkenneth

There are built in tools for the DOM in Python. Also I'm using OSX to
do XML parsing but I'm using the tools available from 4suite.
 
L

Larry Bates

Just curious if there's any python xml parsing tools built into the Mac (OS 10.4.10 Tiger)? If so,
could anyone
share some simple code (or maybe point me to a web-site) of how to parse xml data from a
file? For example, if I
had a file that contained this:

<colors>
<color base="DeviceGray" />
<color alt="DeviceCMYK" base="Separation">Black</color>
<color alt="Lab" base="Separation">Light Blue</color>
<color alt="ICCBased" base="Separation">Green</color>
</colors>

I'd want to look in the 'colors' xml element, then look at each 'color' xml element inside and
pull any that have
values (which would be Black, Light Blue and Green). I'd like to know how to pull 'attributes'
too.

Thanks very much for your help.

Jay

Python 2.5 has elementtree built into it. You should be able to parse the XML
and extract anything you want.

-Larry
 

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

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top