Skip to Content
0
Oct 28, 2021 at 12:12 PM

Use Xpath filter into groovy script

575 Views Last edit Oct 28, 2021 at 12:13 PM 2 rev

Hello,

Could you please tell me if it is possible to add an Xpath filter into a groovy script ?

Below is my sample in xml, I woul like to apply this filter : "//root/row[reason='ORDER_PREPARED']", then add root tags because they disappear when I apply a si,gle filter into sap cpi. My idea is to get the body into groovy script function, then apply a filter (//root/row[reason/text()='ORDER_PREPARED']) and finally add "<root>""</root>" tags.

<root>

<row>

<period_begin>2021-10-27 07:39:45.090462+00</period_begin>

<period_end/>

<line_id>6</line_id>

<reason>DLC_LIMIT_DAYS_PASSED</reason>

<product_sku>fromagers-halloumi</product_sku>

<sap_ship_to_id/>

<sap_ship_from_id>par-roty</sap_ship_from_id>

<total_stock>18</total_stock>

<sap_idn_id/>

<sap_idn_item_id/>

<sap_po_id/>

<sap_po_item_id/>

<quantity>2</quantity>

<channel>CAJOO</channel>

</row>

<row>

<period_begin>2021-10-27 07:39:45.090462+00</period_begin>

<period_end/>

<line_id>7</line_id>

<reason>DLC_LIMIT_DAYS_PASSED</reason>

<product_sku>pasquier-brioche-tressee-chocolat-630</product_sku>

<sap_ship_to_id/>

<sap_ship_from_id>par-sedaine</sap_ship_from_id>

<total_stock>8</total_stock>

<sap_idn_id/>

<sap_idn_item_id/>

<sap_po_id/>

<sap_po_item_id/>

<quantity>6</quantity>

<channel>CAJOO</channel>

</row>

</root>

Thanks for your help