I am creating XML file using XMLDocument, but when XML node get '&' as data, it converting in "Ampersand(&)amp;" but i need actual value that is '&', Can anyone please tell me how can I achieve it?
Result:
A single &
is illegal in an XML document (outside of CDATA sections; see @rsp's answer), so this is not possible. If there is a verbatim ampersand in your node data, it has to be encoded as &
.
But it's also no problem because any XML reader will decode &
as a literal &
when parsing the XML file.
If it is really necessary to have unescaped ampersands in your XML representation, you can use CDATA sections at the expense of the <![CDATA[
start and ]]>
end around your character data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With