tree.getpath() on xml with default namespace (no prefix)

Having an issue with an xml file that has a namespace, but no prefix. The result of getpath() is showing as '*'Is there a workaround? I must be missing something very basic, but the documentation for getpath() doesn't mention what need to be done in this case (http://lxml.de/xpathxslt.html#generating-xpath-expressions)
##getpath.pyfrom lxml import etreeimport sys xml_file = sys.argv[1]parser = etree.XMLParser(remove_blank_text=True)tree = etree.parse(xml_file, parser)root = tree.getroot() for child in root.iter(): print(tree.getpath(child))
##test1.xml -- with xmlns, but no prefix -- the result is not what I'm expecting<Test xmlns="http://www.test.org/test"> <elem>some text</elem></Test> $ python getpath.py test1.xml/*/*/*
##test2.xml -- without xmlns -- showing the expected results<Test> <elem>some text</elem></Test> $ python getpath.py test2.xml/Test/Test/elem ##test3.xml -- xmlns with prefix -- working as expected<ns:Test xmlns:ns="http://www.test.org/test%22%3E ns:elemsome text</ns:elem></ns:Test> $ python getpath.py test3.xml /ns:Test/ns:Test/ns:elem Cheers,Aaron
participants (1)
-
Aaron Storm