I am trying to filter an XML based on multiple parameters that I have as an input.
I am trying to identify the parent nodes which have the matching records so that I can filter them out and process.
<A>
<B1>
<C1>
<D1>111</D1>
<E1>111</E1>
<F1>
<G1>111</G1>
<H1>
<I1>111</I1>
<J1>111</J1>
</H1>
</F1>
</C1>
</B1>
<B1>
<C1>
<D1>222</D1>
<E1>333</E1>
<F1>
<G1>222</G1>
<H1>
<I1>222</I1>
<J1>222</J1>
</H1>
</F1>
</C1>
</B1>
<B1>
<C1>
<D1>333</D1>
<E1>333</E1>
<F1>
<G1>333</G1>
<H1>
<I1>333</I1>
<J1>333</J1>
</H1>
</F1>
</C1>
</B1>
</A>
Lets say I need to match for the node D1 and E1 and I1, but if there is a 'AND' match from all the parameters, I need to have the node right from <B1> for the result.
<B1>
<C1>
<D1>222</D1>
<E1>333</E1>
<F1>
<G1>222</G1>
<H1>
<I1>222</I1>
<J1>222</J1>
</H1>
</F1>
</C1>
</B1>
I am trying usng the below combination to get the data:
xml..*.((hasOwnProperty("D1") && D1 == "222")&&hasOwnProperty("E1") && D1 == "333"))
But think there is some gap. Can someone fill in and tell me where am I going wrong or is there a better approach to filter an XML? Also, is there something which the filterFunction (collections) can help out with?