Please help getpath () return the full tag names in the getpath () xpath or find a workaround
I am trying to create an xpath for an element in lxml.etree._ElementTree. ElementTree is generated by parsing a 600Kb response from some production WebService.
print elem.getroottree().getpath(elem)
Here is the result:
'/S:Envelope/S:Body/ns5:getPhysicalResponse/*[18]/*[12]/*[6]/*[2]'
Unfortunately, I can not publish the original xml - it contains information about the owner of the client. I also tried to reproduce this result with an automatically generated simple tree of elements that has 100 nested levels, each level has 100 children, but with no luck - getpath () returned xpath with full tag names.
Update Looking at the lxml source code - it points to the tree.h xmlGetNodePath method from the libxml2 library. So this is the behavior of libxml2.
Updating By performing more tests, I realized that this happens every time a tag has no default namespace.
source share