views:

368

answers:

3

Hello All

I have some special characters in my data inside xml.So i am getting error to handle them.

<SubFilePath>http://d2coa5o205622p.cloudfront.net/newswatchforweb&amp;amp;autoPlay=true&amp;amp;autoRewind=false&lt;/SubFilePath&gt;

"'=' is an unexpected token. The expected token is '";

I know how to handle other special like "<",">" ,"\"" ,"\'" ,"&" but how can i handle the "="?

I am using c#

+4  A: 

Wrap your data inside a CDATA block.

Or use &#61;

see: http://www.theukwebdesigncompany.com/articles/entity-escape-characters.php

slebetman
You are right @@Slebetman... using CDATA my problem solve.Can you please tell me one thing which one is batter to use CDATA or format string? can you please explain me... Thanks for your help
Pankaj
CDATA is the simplest as long as your data does not itself contain the CDATA terminator. With CDATA you don't need to parse your data and escape troublesome characters.
slebetman
+1  A: 

If you use one of the XML APIs to write your XML, then there will not be a problem. Use XmlWriter or XElement.

John Saunders
A: 

If you have an associated XSL schema, then you should also define this element with the type "anyURI", like this :

<xs:element name = "SubFilePath" type = "xs:anyURI" />

See this book

jruillier