I used MINIDOM, but it does not provide xpath methods.
Now I'm trying to use libxml2, but it's hard for me to get the attribute values.
My xml extract is as follows:
<Class name="myclass1" version="0"> <Owner user-login="smagnoni"/> </Class>
and I wrote the following code:
import libxml2 doc = libxml2.parseFile(file) ris = doc.xpathEval('*/Class[@name="'+className+'" and @version="'+classVersion+'"]/Owner') print str(ris[0])
which returns:
<Owner user-login="smagnoni"/>
How do I get only smagnoni? Parsing a string manually seems like overworked work. but I did not find a method comparable to .getAttribute("attribute-name") in the minidom.
Can someone suggest the right method or direct me to the documentation?
Stefano
source share