Using XSLT and XPath 1.0, I have a string I want to escape for use on a URL, for example:
<description>one word & another</description>
So, the text() of the description element should get URL escaped.
How would I do this?
Using C# (XslCompiledTransform) the code would be:
string a = Server.UrlEncode("one word & another");
And would produce:
one+word+%26+another
Any suggestions?
There's nothing built in to do this, but rather than reinvent the wheel there are style sheets already out there e.g.:
http://skew.org/xml/stylesheets/url-encode/
The transforms are straightforward but (hopefully) someone else will have done the debugging for you...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With