Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: Bryt ParkHi
I am trying to use "XMLpy File" node to parse a XML file, however it only works on files with NO name space. How do I get it to work on files with name spaces?
Another question: where there are repeated elements (child node "A2" below"), how can get all repeated elements in the result.
I can NOT use "XML Data" node which is probably better designed to handle XML files, as I need to extract particular elements ( some are repeated elements) from a source file that contains one single giant message with complex message structure ( 8 - 10 layers of child nodes and attributes)
Here's the script:
data = {}
@elementHandler('/Root/A')
def EntryHandler(element):
data['MsgId'] = str(element.A1)
outputRecord(data, 0)
Here are the data:
- With NameSpace
<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns="
http://www.a.org/a-5/a" >
<A>
<A1>X</A1>
<A2>XA</A2>
<A2>XB</A2>
<A4>X</A4>
</A>
<B>X</B>
<C>
<partyReference href="X"/>
</C>
<D>X</D>
</Root>
-Without NameSpace
<?xml version="1.0" encoding="UTF-8"?>
<Root ABc="
http://www.a.org/a-5/a" >
<A>
<A1>X</A1>
<A2>X</A2>
<A3>X</A3>
<A4>X</A4>
</A>
<B>X</B>
<C>
<partyReference href="X"/>
</C>
<D>X</D>
</Root>