asp.net - decoding cdata content within xml -


A customer has sent us an XML file with CDATA content that is XML encoded i.e. & amp; Lt ;! [CDATA [Some Content]] & amp; Gt;

What is the best way to replace content in an XML file with A decoded version in ASPNX?

Thanks

This (without asking the customer to send us the correct file) It may be that you do not want to, but it will give you at least one start:

  Using the system; Using System.Collections.Generic; Using System.Text; Using System.Xml; Using the system. Security; Name space cssandbox {class program {static zero main (string [] arg) {string oldXml = "& lt; root» gt; child & gt; not cdATA here & lt; / child & gt; & lt; child & Gt; & lt ;! [CDATA [illegal xml & lt; & gt; 'Bobby Tables]] & gt; & lt; / child & gt; & lt; child & gt; & lt; child & gt; ; & Lt ;! [CDATA [more CDATA & amp; amp;]] gt; & lt; / child & gt; & lt; / child & gt; & lt; / root & gt; "; Console.WriteLine (oldXml); XmlDocument Document = New XmlDocument (); Doc.LoadXml (oldXml); Processnodes (Doctor, Doctor Shishuns); String newxml = doc.OuterXml; Console.WriteLine (newXml); Console.ReadLine (); } Fixed Zero Process Nodes (XML Document Dock, XML Nodist Nodes) {foreach (XMLNode node in nodes) {if (node.HasChildNodes) {ProcessNodes (doc, node.ChildNodes); } Else {if (node ​​is XmlCDataSection) {string cdataText = node.InnerText; Node.ParentNode.InnerXml = SecurityAlment. Escape (cdTetext); It assumes that your CDT block is only the only child of the current node (according to my test).   

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -