[XML-SIG] Represent XML
Sbaush
sbaush at gmail.com
Fri Jan 27 16:52:16 CET 2006
Thanks very much for your answer...
One question:why amara is the best solution? Can't we do it with the
standard python xml.dom or minidom?
2006/1/27, Luis Miguel Morillas <morillas at gmail.com>:
>
>
>
> 2006/1/27, Sbaush <sbaush at gmail.com>:
> >
> > Hi all.
> > I attach to you a example XML file to parse and the demo of my
> > objective.
> > The iptRequest.xml is the file to parse in one mode. I can't parse it.
> > The demo.py is my ideal result, manually built, that should be built by
> > parsing the XML.
> > How can i do to do it?
> > Bye all!
> >
>
> Easy, here you have the data you need, then compose your strings :)
>
> import amara
> doc = amara.parse('iptRequest.xml')
> for table in doc.xml_xpath (u'//table'):
> data = {}
> data['chain'] = table.chain
> data['poli'] = table.policy
> for rule in table.xml_children:
> if not isinstance(rule, unicode):
> for at in rule.xml_attributes.keys ():
> data[at] = eval('rule.'+at)
> print data # now build your string
>
>
>
> Saludos,
>
> --
>
> Luis Miguel
--
Sbaush
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/xml-sig/attachments/20060127/571b3cc3/attachment.htm
More information about the XML-SIG
mailing list