Special Characters in XML

2019-04-20 15:39发布

I am creating a left navigation system utilizing xml and xsl. Everything was been going great until I tried to use a special character in my xml document. I am using » and I get th error.

reason: Reference to undefined entity 'raquo'.
error code: -1072898046

How do I make this work?

9条回答
劫难
2楼-- · 2019-04-20 16:29

I found myself googling for such info a lot, so decided to post a matrix on my own site for the simple purpose of quickly being able to do a lookup:

http://martinkool.com/characters

Use the &#...; form indeed.

查看更多
姐就是有狂的资本
3楼-- · 2019-04-20 16:31

This is an issue because not all HTML entities are XML entity. You can import the DTD of HTML into your document as Pat suggested, or do one of the following:

Replace all the occurances of the special character with the numeric entity code:

» becomes »

Wrap all occurances of the special characters in a CDATA Tag

<![CDATA[&raquo;]]>

Define entitys at the top of your document

<!DOCTYPE ROOT_XML_ELEMENT [ <!ENTITY raquo "&#187;"> ]>
查看更多
Juvenile、少年°
4楼-- · 2019-04-20 16:32

Are you using the » symbol directly or are you defining it as &raquo; ? If you're using the escaped symbol, did you forget the semicolon?

查看更多
登录 后发表回答