所以我有这样的XML:
<bar>
<foo>Something</foo>
<baz>
<foo>Hello</foo>
<zap>Another</zap>
<baz>
<bar>
我想删除所有的foo节点。这样不行
params = xml.xpath('//foo')
for n in params:
xml.getroot().remove(n)
给予
ValueError: Element is not a child of this node.
做这件事的好方法是什么?
Tags:
尝试:
从它的父级而不是根级移除它 (除非它是根元素的子元素)
相关问题 更多 >
编程相关推荐