Libxml is a Python wrapper around the libxml2 library. Other APIs are PyXML and 4Suite. The libxml2 wrapper API enables the developer to use XPath expressions for iteration of XML files. The following example describes the usage.
Sample XML file:
Rafael Sobek
Sample XML file:
<?xml version="1.0"?> <orders> <order id="1" name="Red T-Shirt" customerId="2" count="2"/> <order id="2" name="Blue T-Shirt" customerId="2" count="1"/> </orders>XML processing code:
import libxml2
def listAllOrders(xmlFile):
doc = libxml2.parseFile(xmlFile)
for order in doc.xpathEval('//order'):
rowResult = "OrderId is " + order.xpathEval('@id')[0].content
print rowResult
doc.freeDoc()
listAllOrders('sample.xml')
Output:
OrderId is 1 OrderId is 2Regards
Rafael Sobek

Thank you very much ! I had to update my python modules and your very simple example allows me to switch easily from Minidom to LibXML2 to read an XML config file. It works well with Python 2.7.1
nicolas