Amr Elnashar
Amr Elnashar

Reputation: 1769

Saving Url inside xml element

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&storyID=36229</SourceUrl>**

any suggestions!

Upvotes: 4

Views: 10027

Answers (3)

dret
dret

Reputation: 211

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.)

Upvotes: 2

nickytonline
nickytonline

Reputation: 6981

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

Upvotes: 1

roman
roman

Reputation: 11278

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]]>

Upvotes: 13

Related Questions