Submitted by edwardwright on Wed, 01/16/2008 - 00:00
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

Bent Rønne

Wed, 01/16/2008 - 00:00

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

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