Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL and the & ampersand

Tags:

url

escaping

xslt

Using XSLT and XPath 1.0, I have a string I want to escape for use on a URL, for example:

<description>one word &amp; 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?

like image 973
Matt W Avatar asked Nov 20 '25 02:11

Matt W


1 Answers

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...

like image 158
FinnNk Avatar answered Nov 23 '25 04:11

FinnNk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!