I am new to python xml parsing. I am parsing an xml file using elementtree concept.
I went through the domumentation and i have written a script in python.
doc = parse(filePath)
name = doc.getElementsByTagName('package')
print(name)
child_name = name[0]
print(child_name)
print(child_name.tag)
print(child_name.attrib)
The code works to an extent, but the output of child_name.tag and child_name.attrib does not work. When i execute i get his error:
AttributeError: 'Element' object has no attribute 'tag'
In the xml file for the elements the package has id, name, alias , comments desc and so on. I need to access these stuffs.
Can anyone please tell me how i should approach this problem