如何在链接中生成带有特殊符号的 XML 站点地图? [英] how to generate XML sitemap with special symbols in the link?

查看:33
本文介绍了如何在链接中生成带有特殊符号的 XML 站点地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我正在尝试为我的网站生成谷歌站点地图,如何使链接包含如下特殊符号:

<loc>http://example.com/alf-xxx-yyy"--cache</loc>

我该如何处理这些字符???我试过 urlencode 但这不起作用:((感谢您的帮助

解决方案

您所指的特殊字符是方向性弯引号 ".您可以分别对那些字符 &#8220;&#8221; 使用数字实体引用.

http://www.dwheeler.com/essays/quotes-in-html.html

<块引用>

如果您正在创建 HTML、SGML 和 XML直接,也许使用文本编辑器或编写程序,始终使用十进制数字字符引用"用于卷曲单引号和双引号字符(这些标记称为智能引语"、卷曲引语"、卷曲引号"、卷曲引号"或弯曲的引号").

换句话说,对于左右双引号,使用 &#8220;&#8221; - 和左和正确的单引号(和撇号),使用 &#8216;&#8217;- 你会很高兴你做到了.这种方法符合所有国际标准,工作基本上无处不在.

左双引号 = &#8220;=右双引号 = &#8221;= "左单引号 = &#8216;= ‘右单引号 = &#8217;= ’

<块引用>

通过这样做,您的文本将看起来擅长各种各样的浏览器和查看器,你可以轻松剪切和粘贴部分数据HTML、SGML 和 XML 文档之间(让你动态查询和从现有材料创建新材料材料,无需处理翻译的复杂性字符集之间).

Hi I am trying to generate google sitemap for my site, how can i make link to contain special symbols like below:

<url>
   <loc>http://example.com/alf-"xxx-yyy"--cache</loc>
</url>

how can i handle such characters??? i have tried urlencode but this doesn't work :(( Thanks for your help

解决方案

The special characters that you are referring to are the directional curly quotes " and ". You can use the numeric entity reference for those characters &#8220; and &#8221;, respectively.

http://www.dwheeler.com/essays/quotes-in-html.html

If you’re creating HTML, SGML, and XML directly, perhaps using a text editor or writing a program, always use "decimal numeric character references" for curling single and double quote characters (these marks are called "smart quotes," "curly quotes," "curled quotes," "curling quotes," or "curved quotes").

In other words, for left and right double quotation marks, use &#8220; and &#8221; - and for left and right single quotation marks (and apostrophes), use &#8216; and &#8217; - and you’ll be glad you did. This approach complies with all international standards, and works essentially everywhere.

Left Double Quotation Mark   =   &#8220; = "
Right Double Quotation Mark =   &#8221; = "
Left Single Quotation Mark   =   &#8216; = ‘
Right Single Quotation Mark =   &#8217; = ’

By doing this, your text will look good on a very wide variety of browsers and viewers, and you can easily cut-and-paste portions of data between HTML, SGML, and XML documents (letting you dynamically query and create new material from existing material, without having to deal with the complexities of translating between character sets).

这篇关于如何在链接中生成带有特殊符号的 XML 站点地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆