小编Rob*_*Rob的帖子

Best way in lxml to test if an element is the root

I am new to python and xml parsing, so this may be a very dumb question. What is the best way to test if a given element if it is the root if the root is not known? So for example, given a generic test.xml structure;

<root>
<child1>
<child2>
<child3>Some Text</child3>
Run Code Online (Sandbox Code Playgroud)

And you have a function that takes in elements only. The only way I have come up so far is something like this, but requires the root to be …

python xml lxml

2
推荐指数
1
解决办法
826
查看次数

标签 统计

lxml ×1

python ×1

xml ×1