对实体“foo”的引用必须以';'结尾分隔符 [英] The reference to entity "foo" must end with the ';' delimiter
问题描述
我使用Google checkout沙盒生成的HTML代码,它在HTML页面中工作正常。当我在XHTML页面中放置相同的代码时,它会抛出下面的异常:
实体w的引用必须以' ;'delimiter
它引用URL中的请求参数 w
以下 src
属性:
<输入类型=图片名称=Google Checkoutalt =通过Google快速结帐
src =http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=211512493599623&w=180&h=46& style = white& variant = text& loc = en_US
height =46width =180/>
这是如何引起的,我该如何解决它?
& amp;
而不是&
: src =... 9623& amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; ; loc = en_US
&
表示编码实体的开始,例如<
< 或的
为& lt;
& amp; &
。在你的情况下,解析器试图将& w
解释为一个实体。但实体总是以;
结尾,因此如果缺少;
,则会显示错误消息。
I have Google checkout sandbox generated HTML code which works fine in HTML page. When I put the same code in XHTML page, it throws the below exception:
the reference to entity "w" must end with the ';' delimiter
It's referring the request parameter w
in the URL in the below src
attribute:
<input type="image" name="Google Checkout" alt="Fast checkout through Google"
src="http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=211512493599623&w=180&h=46&style=white&variant=text&loc=en_US"
height="46" width="180" />
How is this caused and how can I solve it?
The ampersand &
is a special character in HTML and XML. If you want to use it as a normal character, you have to encode it correctly. Write &
instead of &
:
src="...9623&w=180&h=46&style=white&variant=text&loc=en_US"
&
denotes the start of an encoded entity, such as <
for <
, or &
for &
. In your case the parser tries to interpret &w
as an entity. But entities are always terminated by an ;
, thus if the ;
is missing you get the error message.
这篇关于对实体“foo”的引用必须以';'结尾分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!