Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The reference to entity "foo" must end with the ';' delimiter

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?

like image 302
Adnan Avatar asked Jun 26 '11 12:06

Adnan


1 Answers

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.

like image 129
Floern Avatar answered Oct 16 '22 15:10

Floern