Possible ways of filtering the XML Response?

We have a scenario,wherein the back-end sends an XML response having more than 2000 elements and we need to filter out around 150-200 elements.

What are the possible ways of achieving it?

ex:

Original response :

<p1>

<p2>

<p2 : sub 1></p2 : sub 1>

<p2 : sub 2></p2 : sub 2>

<p2 : sub 3></p2 : sub 3>

</p2>

<p3>

<p3: sub 1></p3 : sub 1>

<p3 : sub 2></p2 : sub 2>

<p3 : sub 3></p3 : sub 3>

</p3>

<p4></p4>

.

.

.

</p1>

Filtered response :

<p1>

<p2>

<p2 : sub 1></p2 : sub 1>

</p2>

<p3>

<p3: sub 1></p3 : sub 1>

<p3 : sub 2></p2 : sub 2>

</p3>

<p4></p4>

.

.

.

</p1>

Note : I have tried with XSL Transform wherein i explicitly defined my filtered response structure.

Seeking for Best solution !!

0 4 814
4 REPLIES 4

@Maivizhi

You can also use Javascript Policy to modify the response before it's sent to the client. XSL Transform also works and i think it's available for exact same reason. Any reason you are looking for other than XSL Transform policy ?

Thanks !!@Anil Sagar

Our only concern is code optimization.As of now we are using XSLT which will explicitly define the structure of final response (which comes around 150-200 lines).

Is there any best way of doing it in XSL Transform?

@Maivizhi , I think above question is outside Apigee scope. You might need to refer stack overflow for optimisation of XSLT. Find some articles related to same here.

Sure @Anil Sagar

Thanks!