Saving Url inside xml element
I got this error An error occurred while parsing EntityName. Line 1, position 61.
when saving this url
http://w开发者_StackOverflow社区ww.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!
you get this error because of the &
- either replace it with &
or store your urls in a cdata section - i.e. <![CDATA[your-url-here]]>
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 '&', 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.)
THe & is killing you. Put it in a CDATA section.
精彩评论