1
Reply

Add CData Section to existing xml string

Madhu Jayapal

Madhu Jayapal

Jan 19 2011 2:06 AM
13.8k
Hi Guys,
Requirement is to add CData section to existing XML string of below format
<ContactSet>
<Contacts>
<Contact>
<ContactID>33493</ContactID>
<CustomerID>6663</CustomerID><Fax />
<EmailID>[email protected]</EmailID>
<DateNoMailRequested>1970-01-01T05:30:00</DateNoMailRequested>
<Password>nJzVu@&#x8;&#x5;&#xB;{YxE&#x5;&#x6;3&#x6;</Password>
<Phone>918043510100</Phone>
<Summary>Hi!, Awaiting for your reply. Thanks & Regards</Summary>
</Contact>
</Contacts>
</ContactSet>

Required output is to be like this
<ContactSet>
<Contacts>
<Contact>
<ContactID><![CDATA[33493]]></ContactID>
<CustomerID><![CDATA[6663]]></CustomerID><Fax />
<EmailID><![CDATA[[email protected]]]></EmailID>
<DateNoMailRequested><![CDATA[1970-01-01T05:30:00]]></DateNoMailRequested>
<Password><![CDATA[nJzVu@&#x8;&#x5;&#xB;{YxE&#x5;&#x6;3&#x6;]]></Password>
<Phone><![CDATA[918043510100]]></Phone>
<Summary><![CDATA[Hi!, Awaiting for your reply. Thanks & Regards]]></Summary>
</Contact>
</Contacts>
</ContactSet>

Basically without CData section when i try to load xml string into XDocument, .net is giving hex decimal parsing error.
Hoping adding CData section will solve the problem.

Awaiting for reply

Thanks in advance


Answers (1)