theta
theta

Reputation: 25611

Return the XML source for the node with lxml

Please imagine XML node in variable n.

If I access this node through MSXML, I can get node's XML source with .xml property, i.e. n.xml will return whole node source.

How can I do the same with lxml?

Upvotes: 0

Views: 72

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1122292

Use the .tostring() method:

from lxml import etree

print etree.tostring(node)

Upvotes: 2

Related Questions