tags:

views:

36

answers:

3

I got this error An error occurred while parsing EntityName. Line 1, position 61. when saving this url http://www.autorentalnews.com/t_inside.cfm?action=news_pick&storyID=36229

I don't know why i can't save url like this inside xml file

the element wrote like that

<New>
<ID>8b269f29-69a1-4551-8d72-4602df4e2c7e</ID>
<Title>Industry Rallies Against Ariz. Rental Car Tax</Title>
**<SourceUrl>http://www.autorentalnews.com/t_inside.cfm?action=news_pick&amp;storyID=36229&lt;/SourceUrl&gt;**

any suggestions!

+3  A: 

you get this error because of the & - either replace it with &amp; or store your urls in a cdata section - i.e. <![CDATA[your-url-here]]>

roman
thanks .........
Amr Elnashar
A: 

THe & is killing you. Put it in a CDATA section.

nickyt
@AmRoSH - Just like Roman shows you in his updated answer. @Roman - Beat me by two seconds!
nickyt
A: 

the '&' is a special character in XML and has to be escaped then it's use literally. otherwise, the XML parser is seeing the '&' and expects an entity. then it reads 'storyID' and expects that to be the entity name. then it reads '=' and gets upset because entity names cannot contain '=' and have to be terminated with a ';'. the escape sequence for using a '&' literally is '&amp;', as suggested by others. wrapping text in CDATA sections disables scanning for special characters and thus achieves the same purpose.

(it's kind of ironic that while posting this i have to carefully compose and fix the entry so that stackoverflow's editor does not get confused; it's processing XML/HTML too, after all.)

dret