我有這樣的XML結構,Minidom:我如何檢查我是否有預期的根和兒童?
<root>
<child1>
</child1>
<child2>
</child2>
<child3 />
<extendedchild:name>
</extendedchild:name>
</root>
如何檢查與minidom命名,這根是root
,而孩子總是跟隨着要素是什麼?
child1
child2
child3
extendedchild
我想也可以打印出來有根或沒有在上面的 「兒童名單」 中的元素(outofroot,notachild): ...
<notachild />
</root>
<outofroot />
編輯 : 看來,outofroot
元素被minidom
解析器處理,它給出xxxxxxx.xml has an error: junk after document element: line 12, column 0
似乎'outofroot'元素被分析器處理,它提供了'xxxxxxx.xml有一個錯誤:文檔元素後的垃圾:行12,列0' –