Quantcast
Channel: Writing special characters to xml in c# - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Kirill Polishchuk for Writing special characters to xml in c#

$
0
0

XDocument escapes them itself.

<Student><ID>><&"</ID></Student> isn't well-formed XML.

Well-formed version, which produces XDocument is:

<Student><ID>&gt;&lt;&amp;"</ID></Student>

You can use this code (uses CDATA):

XElement Config = new XElement("Student", new XElement("ID", new XCData("><&\"")));

Output:

<Student><ID><![CDATA[><&"]]></ID></Student>

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>