parsing nested unbounded XML fields with ElementTree

Chris Angelico rosuav at
Mon Nov 25 23:30:44 CET 2013

On Tue, Nov 26, 2013 at 9:22 AM, Larry.Martell at
<Larry.Martell at> wrote:
> I have an XML file that has an element called "Node". These can be nested to any depth and the depth of the nesting is not known to me. I need to parse the file and preserve the nesting. For exmaple, if the XML file had:
> <Node Name="A">
>    <Node Name="B">
>       <Node Name="C">
>         <Node Name="D">
>           <Node Name="E">

First off, please clarify: Are there five corresponding </Node> tags
later on? If not, it's not XML, and nesting will have to be defined
some other way.

Secondly, please get off Google Groups. Your initial post is
malformed, and unless you specifically fight the software, your
replies will be even more malformed, to the point of being quite
annoying. There are many other ways to read a newsgroup, or you can
subscribe to the mailing list python-list at, which carries
the same content.


More information about the Python-list mailing list