<span class="gmail_quote"></span><br><div><span class="gmail_quote">2006/1/27, Sbaush &lt;<a href="mailto:sbaush@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">sbaush@gmail.com</a>&gt;:</span>
<div><span class="e" id="q_1090c89f884f19a7_1"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<span class="gmail_quote"></span><span class="gmail_quote"></span>Hi all.<br><div><span>I attach to you a example XML file to parse and the demo of my objective.<br>The iptRequest.xml is the file to parse in one mode. I can't parse it.
<br>The demo.py is my ideal result, manually built, that should be built by parsing the XML.
<br>How can i do to do it?<br>Bye all!</span></div></blockquote></span></div><div><br>Easy, here you have the data you need, then compose your strings :)<br><br>import amara<br>doc = amara.parse('iptRequest.xml')<br>for table in 
doc.xml_xpath
(u'//table'):<br>&nbsp;&nbsp;&nbsp; data = {}<br>&nbsp;&nbsp;&nbsp; data['chain'] = table.chain<br>&nbsp;&nbsp;&nbsp; data['poli'] = table.policy<br>&nbsp;&nbsp;&nbsp; for rule in table.xml_children:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if not isinstance(rule, unicode): <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for at in rule.xml_attributes.keys

():<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; data[at] = eval('rule.'+at)<br>&nbsp;&nbsp;&nbsp; print data&nbsp; #&nbsp; now build your string<br></div></div><br><br><br>Saludos, <br><br>--<br><span class="sg"><br>Luis Miguel

</span><br clear="all"><br>