XML : How to escape Special character in XML

I have XML data in string and tried to convert that string in to XML using XmlDocument xl=new XmlDocument(); xl.LoadXml(mystring);

It was not parsing because my string has special character in xml element like below.

  <ROOT>   <SUB>     <DATA>name < lastname</DATA>     <DATA>Myname > lastname</DATA>     <DATA>some special character in between text</DATA>      ......      .....   </ROOT>  </SUB>    

There were many in my xml. It was generating dynamically.

I have tried to change < < > > but it was replacing other XML tags.

How to escape above special characters without change other XML tags ?

Please help me to resolve this

No comments:

Post a Comment