Represent XML

Luis Miguel Morillas <[email protected]>
Newsgroups gmane.comp.python.xml
Message-ID <[email protected]>
2006/1/27, Sbaush <[email protected]>:
>
> 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

_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.