Forums
Using IceBreak I'm trying to parse some XML data using XPath to select on some attributes. My test XML data looks like this:
<?xml version="1.0" encoding="UTF-8" ?> <root> <data foo"1">one</data> <data foo"2">two</data> <data foo"3">three</data> </root>
The XML is read into an ILOB, and then in RPG I do this:
Path = '/root/data[@foo="2"]'; ... some HTML <% = XML_GetValue(xmlPtr: Path : 'N/A') %>
I always get the result "three", i.e. the last <data> tag, no matter what a specify in the XPath attribute specifier. With given path for example, it should return "two".
Any ideas?
Thanks,
Edward
Re: Parsing XML, XPath and attributes with IceBreak
Hi Edward,
To be sure that we talk the same I’ll to have the IceBreak version you use. You can find it two ways:
1. From the Administration menu you can find the version and Build number at the top right corner.
2. From 5250 go IceBreak and use the following command: “dspdtaara svcver”
I hope to hear from you soon.
Best regards,
Bent Ronne
System & Method Technologies
Re: Parsing XML, XPath and attributes with IceBreak
Hi Bent,
Thanks for your rapid reply. Here's the information I've found:
IceBreak/V2R02BLD0185
Regards,
Edward
Re: Parsing XML, XPath and attributes with IceBreak
Hi Edward;
The reason is that "index by attibute" feature of xPath is not supportet in the build 185.
It is however added in the next build.
Until then you can reach the value with "index by number"
like:
for i = 1 to num(XML_GetValue(xmlPtr: Path + '[UBOUND]': '0');
if (XML_GetValue(xmlPtr: Path + '[' + %char(i) + ']@foo': '') == key );
myvalue = XML_GetValue(xmlPtr: Path + '[' + %char(i) + ']': 'N/A');
endif;
endfor;
Best regards
Niels Liisberg
Re: Parsing XML, XPath and attributes with IceBreak
Hello,
Thanks for the reply, and the workaround. Good to see that feature's coming too.
Thanks,
Edward
Re: Parsing XML, XPath and attributes with IceBreak
Incidentally, my test XML was also wrong, my attributes were misisng an '=' sign
<root>
<data foo="1">one</data>
<data foo="2">two</data>
<data foo="3">three</data>
</root>
Re: Parsing XML, XPath and attributes with IceBreak
Hi Edward;
Yeah - I saw that. But I understood you. and never the less, the work-around works and the feature is on its way....
Best regards
Niels Liisberg