且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何处理 XML 中 URL 中的特殊字符

更新时间:2023-11-04 14:17:10

& 替换 & 不应该破坏 url.您是否遗漏了 ;?

Replacing & with & shouldn't break the url. Did you left out the ;?

更好的解决方案是您应该将其包装在 CDATA 标签中:

Better solution is you should wrap that in a CDATA tag:

<![CDATA[ http://maps.google.com/FortWorth&Texas,more+url;数据 ]]>

<![CDATA[ http://maps.google.com/FortWorth&Texas,more+url;data ]]>

它告诉 XML 解析器将其视为文本而不是解析 &.

Which tells the XML parser to treat it as text and not parse the &.