[Python-au] simple XML->Dict tool
Grant McDonald
gmcdonald at infocomp.com
Thu Sep 15 06:12:31 CEST 2005
David Mertz has written a collection of utilities:
http://gnosis.cx/download/Gnosis_Utils-current.tar.gz
One of which is gnosis.xml.objectify which returns python objects from xml.
Check it out, it may be what you're after.
G
-----Original Message-----
From: python-au-bounces at python.net
[mailto:python-au-bounces at python.net]On Behalf Of Darryl Ross
Sent: 15 September 2005 13:28
To: python-au at python.net
Subject: [Python-au] simple XML->Dict tool
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hey All,
I'm trying to convert a simple xml document into a python dictionary,
similar to SimpleXML for PHP and XML::Dumper for Perl.
The XML documents I'm loading look like this:
> <?xml version="1.0" encoding="utf-8" ?>
> <root xmlns="urn:schemas-upnp-org:device-1-0">
> <specVersion>
> <major>1</major>
> <minor>0</minor>
> </specVersion>
> <device>
> <deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
> <friendlyName>AXIS 206M - 00408C6A556E</friendlyName>
> <manufacturer>AXIS</manufacturer>
> <manufacturerURL>http://www.axis.com</manufacturerURL>
> <modelDescription>AXIS 206M Network Camera</modelDescription>
> <modelName>AXIS 206M</modelName>
> <modelNumber>206M</modelNumber>
> <modelURL>http://www.axis.com</modelURL>
> <serialNumber>00408C6A556E</serialNumber>
> <UDN>uuid:42617369630000000000-00-40-8c-6a-55-6e</UDN>
> <serviceList>
> </serviceList>
> <presentationURL>http://172.29.101.100</presentationURL>
> </device>
> </root>
And I would (ideally) like to be able to do something like:
> xmlobj = xml2dict('upnp.xml')
> print xmlobj.root.device.serialNumber
Does anyone have any pointers to something that would do what I need, or
even some decent documentation on how to write a module to do it?
TIA,
Darryl
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDKOpV/XQ6DbmPjokRAoSMAJ9A1z5LVj2o8prYl3p0RQVsUawiAgCfYGQV
2QDmXur8Xp92zJvIEcQSsao=
=A15a
-----END PGP SIGNATURE-----
_______________________________________________
python-au maillist - python-au at starship.python.net
http://starship.python.net/mailman/listinfo/python-au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://starship.python.net/pipermail/python-au/attachments/20050915/aad9f084/attachment.htm
More information about the python-au
mailing list