How to get the xml element path by using xml.etree.elementtree instead of lxml?

115 Views Asked by At

I'm new to python, I'm using xml.etree.elementtree module to parse the xml file. while parsing trying to get the xml element path which is having the value.

for example:

<root>
  <a>
     <b>Hello</b>
     <b1>Hi</b1>
  </a>
  <c>
    <d>Welcome</d>
    <e>Sample xml</e>
  </c>
</root>

here I want to get the element path, which is having value

root/a/b
root/a/b1
root/c/d
root/c/e

like in lxml module we can get it with the help of getelement(). But, how can we achieve the same by using the module xml.etree.elementtree.

0

There are 0 best solutions below