I’m new to XSL and I’m looking for a way to replace text in XML.
My source XML is:
<A>
<key>One</key>
<string>value1</string>
<key>Two</key>
<string>value2</string>
<key>Three</key>
<string>value3</string>
</A>
What I want is to replace only one of the element.
The result should be:
<A>
<key>One</key>
<string>value1</string>
<key>Two</key>
<string>xxx</string> <---- change this (for key Two)
<key>Three</key>
<string>value3</string>
</A>
How to create an xsl stylesheet to manage this?
Thanks in advance!
This seems to do the trick:
The key fragment is the use of the
preceding-siblingaxis. All available axes are documented here in the xpath specification.