im trying to read xml file to array or list the xml file has multiple child elements :
<Items>
<Company CompanyName="company name">
<Category CategoryName="main category name" />
<Category CategoryName="sub category name">
<Product MAKAT="SKU">
<Name>name</Name>
<Price>XXX</Price>
<IsInStock>Yes</IsInStock>
<URL>url</URL>
</Product>
</Category>
</Category>
</Company>
i have tried to do this :
tree = ET.parse(xmlFile)
root = tree.getroot()
products=[]
for item in tree.findall('Company'):
print(item.attrib)
for subitem in tree.findall('CategoryName'):
print(subitem.attrib)
but i cant reach to all the elements.
i want to reach to all child elements, and insert them into one array . what is the best way to do it in python ?