linq to xml - XML async entity causes validation problems -- how do I escape it? -


i generate static html pages , i've found far best way using xml linq, makes manipulating document quite similar javascript/jquery.

it has worked far, except added addthis button website , following line has caused xmlexception:

<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=xa-51f1474f46ee2d87&async=1&domready=1"></script> 

the exception is:

'=' unexpected token. expected token ';'. line 69, position 114.

i ran line on http://www.xmlvalidation.com , got following result:

110 reference entity "async" must end ';' delimiter.

i've searched google several minutes trying find information on "async" entity or how can around it, many documents claim there 5 entities in xml, such page: http://www.quackit.com/xml/tutorial/xml_entities.cfm

how can escape entity?

bonus question: async entity , why hardly documented anywhere online?

it turns out xml parsers search '&' , assume ampersand start of entity. there 2 ways of escaping ampersands depending on context.

one use xml entity &amp;

since url, 1 should use %26 url encoding

the line, then, follows:

<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=xa-51f1474f46ee2d87%26async=1%26domready=1"></script> 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -