views:

24

answers:

1

Hi I've got some XML that won't validate. I've narrowed down the problem to this bit:

<script type="text/javascript">document.getelementbyid("oxm-1f4a4485-5a1d-45f9-a989-9c65a0b9ceb6").src="http://bid.website.net/display?l=h4siaaaaaaaaad2nmq6cqbrenycw7qjyolfccxmregvcoae0u0sly_agtvaewwn4bg_havwbnebpvmzkkzra_kzzdvoloq4u-hjnp7sii0rxcbzz5vl5kxsrds6wtsfbxmcr9chysuhqbecuckb8cvx4m-pbcxugtdrll6d3dqtihnqukth2yvdkptr67cuzfvlxjlinkul9634lpal_h4mwhso8aabzhw1cdcwjxl6xivgv8agrjxjc_gaaaa==&amp;p=h4siaaaaaaaaabxkmq7cmaxaurcqjjrrsfqqsrm7x3fsrwyvosda8qnj_3ojfgb49o45pblq7e80syzjhopggso9wyzpcpntzkxk1ldtbbi7otmxfj9da1wpjcf10vtxdj9e5_utyj19k2lfssepld5agnqaaaa=&amp;url=http%3a%2f%2flocalhost%2fproject-debug%2fproject.html";&lt;/script&gt;

I put it in an XML validator and it spat out:

This page contains the following errors: error on line 1 at column 16: EntityRef: expecting ';'

Any ideas as to where the missing ';' is supposed to go? Is there another problem?

Thank you.

-Laxmidi

A: 

You have unescaped ampersands & in your URL. They either need to be (a) changed to character entities (&amp;), or (b) enclosed in a CDATA section.

A CDATA section lets you leave special characters like & unescaped, so that'd be easiest:

<script type="text/javascript">
// <![CDATA[
    document.getElementById(...).src="...";
// ]]>
</script>

You can include anything you want inside of a CDATA section aside from the exact character sequence ]]>. The // comments are there to make sure browsers that don't understand CDATA sections ignore the <![CDATA[ and ]]> markers.

By the way, JavaScript is case sensitive. That should be getElementById not getelementbyid.

John Kugelman
Hi John,Thanks so much. I missed the ' -Laxmidi
Laxmidi