0

I need to insert an XmlNode into an XmlDocument with a string returned from a database. The sting in the database is already formatted as Xml. the string from the db also includes characters such as double quotes and < and >. I have tried XmlDocumnetFragement and adding as innerxml. Both error because of the special characters. The data returned by the db looks like this.

<ON STMT = "*" COCE = "COMPSTAT EQ 0"/>
SHOUT WHEN = "EXECTIME" MESSAGE = "Job execution exceeds 30 minutes" TIME = ">030" /> 

I need the output to look like this.

<some other tag /><SHOUT WHEN = "EXECTIME" MESSAGE = "Job execution exceeds 30 minutes" TIME = ">030" /><another tag>

1 Answers1

1

Not exactly figured out the goal of your method, but i recommend you to use XDocument and XElement classes instead of XmlDocument and XmlNode.

And you can search info about characters escaping here: String escape into XML

or search in web "xml document escape special characters".

p.s.: your problem seems similiar to: Special characters with XDocument

Community
  • 1
  • 1
Fragment
  • 1,555
  • 1
  • 26
  • 33