对实体“foo”的引用必须以';'结尾分隔符 [英] The reference to entity "foo" must end with the ';' delimiter

查看:132
本文介绍了对实体“foo”的引用必须以';'结尾分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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/>

这是如何引起的,我该如何解决它?

>是HTML和XML中的一个特殊字符。如果您想将其用作正常字符,则必须正确编码它。 编写& 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 &amp; instead of &:

src="...9623&amp;w=180&amp;h=46&amp;style=white&amp;variant=text&amp;loc=en_US"

& denotes the start of an encoded entity, such as &lt; for <, or &amp; 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屋!

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