1

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

Alaa
  • 4,471
  • 11
  • 50
  • 67

2 Answers2

1

XML has five predefined entities.

In your example, you need to represent the quotes as &quot;.

<url>
<loc>http://example.com/alf-&quot;xxx-yyy&quot;--cache</loc>
</url>

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
pmartin
  • 2,731
  • 1
  • 25
  • 30
1

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

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147