How to (push) parse XML files in Python?



I've already seen this question, but it's from the 2009.

What's a simple modern way to handle XML files in Python 3?


I.e., from this TLD (adapted from here):



<?xml version="1.0" encoding="UTF-8" ?>
<taglib>
<tlib-version>1.0</tlib-version>
<short-name>bar-baz</short-name>

<tag>
<name>present</name>
<tag-class>condpkg.IfSimpleTag</tag-class>
<body-content>scriptless</body-content>

<attribute>
<name>test</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>

</tag>

</taglib>


I want to parse TLD files (Java Server Pages Tag Library Descriptors), to obtain some sort of structure in Python (I have still to decide about that part).


Hence, I need a push parser. But I won't do much more with it, so I'd rather prefer a simple API (I'm new to Python).


No comments:

Post a Comment