Skip to Content
0
Jun 29, 2020 at 04:17 PM

using Xpath axes in SAP CPI to filter XML

2125 Views

Dear community,

I have an XML-structured message in my CPI flow like the following and want to delete all except the first B3 node (and their children). How can I best do this? I have tried the 'filter' in CPI without success, because CPI does not allow the "ancestor-or-self::div" syntax to access parents. "::" is reserved for namespaces (error: namespace prefix ancestor-or-self not defined in name space mapping). Is there any way to escape these special characters? Or is there a better way to achieve the desired output?

<A>

<B1>value</B1>

<B2>value</B2>

<B3>

<C1>

<D1>value</D1>

<D1>value</D1>

</C1>

</B3>

<B3>

<C2>

<D2>value</D2>

<D2>value</D2>

</C2>

</B3>

</A>

Desired output:

<A>

<B1>value</B1>

<B2>value</B2>

<B3>

<C1>

<D1>value</D1>

<D1>value</D1>

</C1>

</B3>

</A>