我目前有一个XML文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<max:CreateMXCLASSIFICATION xmlns:max="http://www.ibm.com/max">
<max:MXCLASSIFICATIONSet>
<max:CLASSSTRUCTURE>
<max:MAXINTERRORMSG>string</max:MAXINTERRORMSG>
<max:CLASSSTRUCTUREID>string</max:CLASSSTRUCTUREID>
<max:CLASSSPEC action="AddChange">
<max:ASSETATTRID>string</max:ASSETATTRID>
<max:ORGID>string</max:ORGID>
<max:SECTION>string</max:SECTION>
<max:SITEID>string</max:SITEID>
<max:CLASSSPECUSEWITH action="AddChange">
<max:OBJECTNAME1>string</max:OBJECTNAME1>
</max:CLASSSPECUSEWITH>
</max:CLASSSPEC>
<max:CLASSUSEWITH action="Replace">
<max:OBJECTNAME2>string</max:OBJECTNAME2>
</max:CLASSUSEWITH>
</max:CLASSSTRUCTURE>
</max:MXCLASSIFICATIONSet>
</max:CreateMXCLASSIFICATION>
我正在尝试提取结构以创建字典,但是现在以下代码在逻辑上有一个我无法发现的错误。目前,当rChild重新分配子节点的NodeList并继续迭代它时,不会检查以下元素的childNodes:
<max:ASSETATTRID>string</max:ASSETATTRID>
<max:ORGID>string</max:ORGID>
<max:SECTION>string</max:SECTION>
<max:SITEID>string</max:SITEID>
<max:CLASSSPECUSEWITH action="AddChange">
以下是我正在使用的代码:
rChild = root.childNodes
for x in range(7):
for y in rChild:
if y.localName is not None:
rChild = y.childNodes
print rChild
非常感谢任何指导!