Page 1 of 1

XML PArse

Posted: Tue May 13, 2008 4:55 pm
by shrey3a
Gurus,

Initially we were getting the XML string in below format <msg><trans><updateRow>
<col name=" SAMPLE "><char>232100905></char></col>
<col name=" ID_NO "><char>232100905></char></col>
</updateRow></trans></msg>

and I was able to parse it correctly by below method

/msg/trans/updateRow/col[@name='SAMPLE']/*/text()
/msg/trans/updateRow/col[@name='ID_NO']/*/text()

Now the message format is changed to

<msg><trans><updateRow>
<col name=" SAMPLE "><char><afterVal>232100905></afterVal></char></col>
<col name=" ID_NO "><char><afterVal>232100905></afterVal></char></col>
</updateRow></trans></msg>

I tried the below options to parse but nothing works

/msg/trans/updateRow/col[@name='SAMPLE']/afterVal/*/text()
/msg/trans/updateRow/col[@name='SAMPLE']/afterVal/text()
/msg/trans/updateRow/col[@name='SAMPLE']/char/afterVal/*/text()
/msg/trans/updateRow/col[@name='SOCIAL_SECURITY_NR'/SAMPLE]/*/text()

I tried all options as above....

Regards,

Posted: Fri May 16, 2008 10:47 am
by belaruska
can you tell which solution worked for you?

Posted: Fri May 16, 2008 6:20 pm
by eostic
This looks like Event Publisher XML..... the char element is missing from two of the xpaths, and where it's included, there's an extra *...

This should have worked:

/msg/trans/updateRow/col[@name='SAMPLE']/char/afterVal/text()

Ernie