How can I get the values for
For the following XML:
<Map>
<mapData>
<entry>
<key>cookie1</key>
<value>656fdhh</value>
</entry>
<entry>
<key>status</key>
<value>True</value>
</entry>
<entry>
<key>cookie3_www.abc.com</key>
<value>gsdfg464</value>
</entry>
<entry>
<key>cookie2</key>
<value>dfdfssdf</value>
</entry>
</mapData>
</Map>
Please let me know how to write XPath to get these 3 field values.
I wrote this to get the value for cookie1
and cookie2
as below.
<xsl:variable name="cookie"><xsl:value-of select="$result/Map/mapData/entry[key and key='cookie1']/value"/></xsl:variable>
<xsl:variable name="cookie1"><xsl:value-of select="$result/*/*/entry[key and key='cookie2']/value"/></xsl:variable>
Here result
is the variable which store the output of the service call ex whole output XML.
I am not able to find a way to get the value of cookie3_www.abc.com
as this value is dynamic, only cookie3
part remains same -- other part are dynamic.
Please suggest how to get this value.
This XPath,
/Map/mapData/entry[starts-with(key,'cookie3')]/value
will return the value
in the same entry
as the key
that starts with cookie3
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.