Reputation: 110492
Given the following:
>>> from lxml import etree
>>> contents=open('file.xml').read()
>>> node=etree.fromstring(contents)
How would I get the root tag name of the node? For example, if the xml were:
<Orders>
<Order>
<Digital_Order>1021</Digital_Order>
</Order>
</Orders>
It would return "Orders"
.
Upvotes: 3
Views: 2286
Reputation: 80111
node
is your root node actually.
But you might be experiencing problems because of the invalid xml, the last orders should be </Orders>
Upvotes: 0