Nov-10-2017, 03:35 PM
Hi,
I have a large multi-level XML document of a complicated structure, without any namespace definition.
I would like to generate a simplified tree view of its structure, so that every possible element from the XML is shown and only once.
As a simplified example take this XML:
I only want to see which elements are in there.
I know there might be visual tools to achieve this, but I need to be able to generate such tree view also directly inside python script.
Thanks for any ideas.
I have a large multi-level XML document of a complicated structure, without any namespace definition.
I would like to generate a simplified tree view of its structure, so that every possible element from the XML is shown and only once.
As a simplified example take this XML:
<data> <timestamp>...</timestamp> <people> <person> <name>...</name> <age>...</age> </person> <person> <name>...</name> <age>...</age> <degree /> </person> <person> <name>...</name> <age>...</age> <degree /> <siblings> <brother>...</brother> <brother>...</brother> <sister>...</sister> </siblings> </person> </people> <cities> <city> <name>...</name> <country>...</country> <continent>...</continent> <capital /> </city> <city> <name>...</name> <country>...</country> <continent>...</continent> </city> </cities> </data>Using Python I would like to generate a view of its structure, looking something like this:
-data- -timestamp- -people- -person- -name- -age- -degree- -siblings- -brother- -sister- -cities- -city- -name- -country- -continent- -capital-So, basically I am not interested in the values, or how many elements of the same type are in the XML, etc.
I only want to see which elements are in there.
I know there might be visual tools to achieve this, but I need to be able to generate such tree view also directly inside python script.
Thanks for any ideas.