Get all the child elements of parent node using xpath expression OSB

2.1k views Asked by At

I am using OSB and have one long XML containing parent and child node.

This is my XML

<XML>
<RefreshLaborApproval2RSP   xmlns:XPathFunction="http://www.oracle.com/XSL/Transform/java/mol.prc.labourapproval.XPathFunction" xmlns:tsd="http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition">
<ERRORCODE>
<VALUE>dfdfdf</VALUE>
</ERRORCODE>
<LABORRECORDS>
<LABORNAT>
<VALUE>569</VALUE>
</LABORNAT>
</LABORRECORDS>
<LABORRECORDS>
<LABORNAT>
<VALUE>218</VALUE>
</LABORNAT>
</LABORRECORDS>
</RefreshLaborApproval2RSP>
</XML>

When I use expression XML/* its gives me the whole XML from <RefreshLaborApproval2RSP> to </RefreshLaborApproval2RSP> and kept the same in one variable called xmlparentNode.

And then when I use $xmlparentNode/LABORRECORDS then I get only istLABORRECORDS child element like below.

<LABORRECORDS>
<LABORNAT>
<VALUE>569</VALUE>
</LABORNAT>
</LABORRECORDS>

But I want all <LABORRECORDS> child elements.

2

There are 2 answers

0
Niubi On

I dont know what exacly you want achieve, but you can:

  1. Assign variable xmlparentNode,

  2. Use For Each for example:

    a) For Each Variable: Laborrecords
    b) XPath: ./LABORRECORDS
    c) In Variable: xmlparentNode
    d) Index Variable: index
    e) Count Variable: count

  3. And then inside For Each do Assign expression: $Laborrecords in variable to get first value, then second.

  4. Do some inserts or something with it.

I do not know if this will solve your problem.

0
Vinoth Kumar K On

The XML expression that you are using is right.

If the XML elements are very long and you are using variable window (during debugging) to see the element returned, there could be a possible chance to data loss.