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 < [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



--
Sbaush
_______________________________________________
XML-SIG maillist  -  XML-SIG@python.org
http://mail.python.org/mailman/listinfo/xml-sig

Reply via email to