only a simple xml reader <tag:id>value</tag:id>

Albert Leibbrandt albert at compuscan.co.za
Thu Feb 9 01:13:42 EST 2006


martijn at gamecreators.nl wrote:

>I'm newbie with that xml stuff.
>
>The only thing I must read is the response I get from a EPP server.
>A response like this:
>
><?xml version="1.0" encoding="UTF-8"?>
><epp xmlns=" http://www.eurid.eu/xml/epp/epp-1.0"
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>xmlns:contact="http://www.eurid.eu/xml/epp/contact-1.0"
>xmlns:domain="http://www.eurid.eu/xml/epp/domain-1.0"
>xmlns:eurid="http://www.eurid.eu/xml/epp/eurid-1.0"
>xmlns:nsgroup="http://www.eurid.eu/xml/epp/nsgroup-1.0"
>xsi:schemaLocation="http://www.eurid.eu/xml/epp/epp-1.0 epp-1.0.xsd
>http://www.eurid.eu/xml/epp/contact-1.0 contact-1.0.xsd
>http://www.eurid.eu/xml/epp/domain-1.0 domain-1.0.xsd
>http://www.eurid.eu/xml/epp/eurid-1.0 eurid-1.0.xsd
>http://www.eurid.eu/xml/epp/nsgroup-1.0 nsgroup-1.0.xsd">
><response>
><result code="1500">
><msg>Command completed successfully; ending session</msg>
></result>
><resData>
><domain:appData>
><domain:name>c-and-a.eu</domain:name>
><domain:reference> c-and-a_1</domain:reference>
><domain:code>2565100006029999</domain:code>
><domain:crDate>2005-11-08T14:51:08.929Z</domain:crDate>
></domain:appData>
></resData>
><extension>
><eurid:ext>
><eurid:result>
><eurid:msg>OK</dnsbe:msg>
></eurid:result>
></eurid:ext>
></extension>
><trID>
><clTRID>clientref-12310026</clTRID>
><svTRID>eurid-1589</svTRID>
></trID>
></response>
></epp>
>----------------
>//<result code="1500">
>//<msg>Command completed successfully; ending session</msg>
>
>what is the official/best way to handle/parse such xml response ?
>
>Thats maybe a better question
>
>  
>
try something like this:

import xml.dom.minidom as dom
doc = dom.parseString("""<?xml version="1.0"?>
<title>The Fascist Menace</title>""")
print doc.getElementsByTagName('title')[0].childNodes[0].data




More information about the Python-list mailing list