XML Response payload as below
<root>
<_1>
<expand>description,lead,url,projectKeys</expand>
<name>ABC</name>
<id>12631</id>
</_1>
<_2>
<expand>description,lead,url,projectKeys</expand>
<name>XYZ</name>
<id>12632</id>
</_2>
<_3>
<expand>description,lead,url,projectKeys</expand>
<name>JKL</name>
<id>12634</id>
</_3>
</root>
Here <_1>,<_2>,<_3> can increase sequentially depends on total count of XML records.
My requirements are to write an XQuery
To identify total count of values in Element nodes (For eg:- 50 i.e last node is <_50>)
Iterate thru all element nodes till 50 (for instance) and pull its corresponding child nodes (for example : expand,name,id)
I had a similar XML response payload, where instead of sequential increase in the element node values (<_1>,<_2>,<_3> ) , it has a fixed name (entries) to all element nodes . (Example below) and I wrote an XQuery to retrieve the values from its child nodes (see below).
<root> <entries> <added>1534815831000</added> <updated>1534815831000</updated> </entries> <entries> <added>1534815832000</added> <updated>1534815832000</updated> </entries> </root>
XQuery was
let $entries := /root/entries
return
for $entry in $entries
return
<entries>
{
<added>{data($entry/added)}</added>,
<updated>{data($entry/updated)}</updated>
}
</entries>
Challenges are
a) When the element node name changes with every record
b)Iteration through all element nodes
Any valuable suggestions are much appreciated.
Thanks