問題描述
我有 Google 結帳沙箱生成的 HTML 代碼,可以在 HTML 頁面中正常工作.當我將相同的代碼放在 XHTML 頁面中時,它會引發以下異常:
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:
對實體w"的引用必須以;"結尾分隔符
the reference to entity "w" must end with the ';' delimiter
它在下面的src
屬性中引用了URL中的請求參數w
:
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?
推薦答案
與號 &
是 HTML 和 XML 中的特殊字符.如果要將其用作普通字符,則必須對其進行正確編碼.用 &
代替 &
:
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"
&
表示編碼實體的開始,例如 <
表示 <
,或 &
用于 &
.在您的情況下,解析器嘗試將 &w
解釋為實體.但是實體總是由 ;
終止,因此如果 ;
丟失,您會收到錯誤消息.
&
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"的引用必須以 ';' 結尾分隔符的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!