I currently have an XML file as follows:
<?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:OBJECTNAME>string</max:OBJECTNAME>
</max:CLASSSPECUSEWITH>
</max:CLASSSPEC>
<max:CLASSUSEWITH action="Replace">
<max:OBJECTNAME>string</max:OBJECTNAME>
</max:CLASSUSEWITH>
</max:CLASSSTRUCTURE>
</max:MXCLASSIFICATIONSet>
</max:CreateMXCLASSIFICATION>
I am trying to extract the structure to create a dictionary, however right now the following code has an error in logic that I cannot spot. Currently when rChild gets reassigned a NodeList of children and continues to iterate through it does not check the childNodes of the following elements:
<max:ASSETATTRID>string</max:ASSETATTRID>
<max:ORGID>string</max:ORGID>
<max:SECTION>string</max:SECTION>
<max:SITEID>string</max:SITEID>
<max:CLASSSPECUSEWITH action="AddChange">
Here is the code that I am using:
rChild = root.childNodes
for x in range(7):
for y in rChild:
if y.localName is not None:
rChild = y.childNodes
print rChild
Any guidance would be much appreciated!
No comments:
Post a Comment