Skip to content
Advertisement

Parsing a XML child element back as a string

I’m trying to parse a complex XML and xpath isn’t behaving like I thought it would. Here’s my sample xml:

JavaScript

Here’s my python code:

JavaScript

I get the output:

JavaScript

when I expected:

JavaScript

What am I doing wrong?

Advertisement

Answer

This XPath will get text and elements as expected

JavaScript

Printing found nodes as OP requested

JavaScript

Result

JavaScript

with_tail argument prevents tail text to be appended to element.

Or

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement