使用 XSLT 和 XPath 1.0,我有一个要转义的字符串以用于 URL,例如:
<description>one word & another</description>
因此,描述元素的 text() 应该进行 URL 转义。
我该怎么做?
使用 C# (XslCompiledTransform) 代码将是:
string a = Server.UrlEncode("one word & another");
并且会产生:
one+word+%26+another
有什么建议吗?
最佳答案
没有内置的东西可以做到这一点,但不是重新发明轮子,而是已经有了样式表,例如:
http://skew.org/xml/stylesheets/url-encode/
转换很简单,但(希望)其他人会为您完成调试...
关于URL 和 & 符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1654674/