from lxml import etree
import os.path
myparser = etree.XMLParser(remove_blank_text=True)
path1 = os.path.join("publicdata", "ind0.xml")
ind_tree = etree.parse(path1, parser=myparser)
ind_root = ind_tree.getroot()
def nodeInfo(node):
print("Tag:", node.tag)
print("Text:", repr(node.text))
print("XML Attributes:", node.attrib)
nodeInfo(ind_root)
for country in ind_root.getchildren():
nodeInfo(country)
nodeInfo(ind_root[1])
Path investigation
ind_root.xpath("/indicators")
ind_root[1].xpath("timedata")