Search code examples
arraysxsltjsonx

XSLT: How to select value from the object based on the particuar value from an JSONX array object


From the below example I need to extract the data of "value" field., when the string field name = "first". How should write the xpath in XSLT for the below JSONX sample to get the desired result.

Example:

<json:array name="filters">
<json:object>
<json:object>
<json:string name="name">first</json:string>
<json:string name="op">eq</json:string>
<json:string name="value">11223333</json:string>
</json:object>
<json:object>
<json:string name="name">second</json:string>
<json:string name="op">eq</json:string>
<json:string name="value">1234</json:string>
</json:object>
<json:object>
<json:string name="name">date</json:string>
<json:string name="op">between</json:string>
<json:string name="value">26/07/2016</json:string>
<json:string name="value2">26/07/2018</json:string>
</json:object>
</json:object>
</json:array>

Thanks,


Solution

  • Try

    //json:object[json:string[@name='name']='first']]
       /json:string[@name='value']/string()
    

    (with a suitable namespace binding of course)