xml question
Larry Bates
larry.bates at websafe.com
Wed Sep 12 16:50:33 EDT 2007
JYOUNG79 at kc.rr.com wrote:
> 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
More information about the Python-list
mailing list