Revision: 44565
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 14, 2011 03:42 by anarres
Initial Code
# Userful: http://blog.doughellmann.com/2010/03/pymotw-parsing-xml-documents-with.html
from xml.etree import ElementTree
foo = """<?xml version="1.0" encoding="utf-8"?>
<ApiResponse Status="OK" xmlns="http://api.namecheap.com/xml.response">
<Errors />
<Warnings />
<RequestedCommand>namecheap.domains.check</RequestedCommand>
<CommandResponse>
<DomainCheckResult Domain="example.com" Available="false" />
</CommandResponse>
<Server>P2136033</Server>
<GMTTimeDifference>--7:00</GMTTimeDifference>
<ExecutionTime>0.688</ExecutionTime>
</ApiResponse>"""
tree = ElementTree.fromstring(foo)
print tree
for node in tree.getiterator():
print node.tag, ": ", node.attrib
print "\n--------------------\n"
for node in tree.getiterator():
if "Available" in node.attrib.keys():
print node.attrib["Available"]
Initial URL
Initial Description
Initial Title
Parsing XML from NameCheap that says my domain is not available
Initial Tags
python, xml
Initial Language
Python