Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using & in URL causes XML error: The reference to entity "foo" must end with the ';' delimiter

I'm trying to get google map image with the following code:

<img src="http://maps.googleapis.com/maps/api/staticmap?center=#{profile.latitude},#{profile.longitude}&zoom=14&size=400x400&sensor=false"/>

but I get exception in my browser which says:

Error Parsing /content/profile.xhtml:
Error Traced [line: 48] The reference to entity "zoom" must end with the ';' delimiter.

How can I avoid interpreting & in URL as XML?

like image 977
xwhyz Avatar asked Jan 02 '12 07:01

xwhyz


1 Answers

Replace & with &amp; as the markup is being parsed as XML and &zoom is being parsed as an HTML entity which does not exist in XML.

like image 150
andyb Avatar answered Nov 15 '22 06:11

andyb