Trying to parse the following Python file using the lxml.etree.iterparse function.
\"sampleoutput.xml\"
-
Item 1
The problem is that XML isn't well-formed if it doesn't have exactly one top-level tag. You can fix your sample by wrapping the entire document in
tags. You also need the
tags to match the query that you're using (description
).
The following document produces correct results with your existing code:
-
Item 1
Description 1
-
Item 2
Description 2