gpt4 book ai didi

URL 和 & 符号

转载 作者:行者123 更新时间:2023-12-04 21:19:52 30 4
gpt4 key购买 nike

使用 XSLT 和 XPath 1.0,我有一个要转义的字符串以用于 URL,例如:

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

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com