Symbol causing error in XML data


Hello Everyone,

As we know that some characters have special meaning in XML data like ampersand (&) is one of them.

So, these characters should be substituted (ie use string replacement) with their respective entity references.

As per XML specification, there are 5 predefined entities in XML:

&lt;    <   less than
&gt;    >   greater than
&amp;   &   ampersand
&apos;  '   apostrophe
&quot;  "   quotation mark

Now alternatively, we can place "text" strings which might contain special characters within a CDATA section so XML parsers will not attempt to parse them.

Here is the solution :

<SomeElement><![CDATA[This & will be ignored]]></SomeElement>

Hope it will helps,

Enjoy

Comments

Popular posts from this blog

Executing PowerShell scripts from C#

HOW TO Use the NumericUpDown Control

Exposing Agile Software Development Myths