[Python-au] simple XML->Dict tool
Darryl Ross
spam at afoyi.com
Thu Sep 15 05:28:21 CEST 2005
-----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-----
More information about the python-au
mailing list