I have a xml file with the following format:
<batch>
<type1 type="application/pdf" file="1234.pdf">
<...></...>
<...></...>
<description>Description 1</description>
<...></...>
<...></...>
</type1>
<type2 type="application/pdf" file="23456.pdf">
<...></...>
<...></...>
<description>Description 1</description>
<...></...>
<...></...>
</type2>
<type1 type="application/pdf" file="1235.pdf">
<...></...>
<...></...>
<description>Description 2</description>
<...></...>
<...></...>
</type1>
</batch>
I want to retrieve a list of type1, type2 within a list of description for that type in the xml. The list result is ['{blabla.com}type1', '{blabla.com/2}type2', '{blabla.com/3}type3', '{blabla.com}type4', etc. ] I tried:
test = ET.parse("...\\index.xml")
type_list = []
for type in test.iter():
type_list.append(type.tag)
type_list = list(set(type_list))
to get all types in xml. But then how can I get all of the description for each type?
The result I want to have:
type1: Description 1, Description 2
type2: Description 1, ...
ugly handling of namespace but should work