I have a class that serializes my object to xml - it's working as expected. Here is how I am writing out the xml file:
My problem is that one of the "nodes" that I am serializing contains XML text. The code above writes out the xml text, but changes all of the < and > to entities (e.g. < becomes < and > becomes >) which is not what I want - I need to keep the xml in this node as xml.
Any clues as to what I need to do?
Code:
'set up a blank namespace to eliminate unnecessary junk from the xml
Dim nsBlank As New XmlSerializerNamespaces
nsBlank.Add("", "")
'create an object for the xml settings to control how the xml is written and appears
Dim xSettings As New System.Xml.XmlWriterSettings
With xSettings
.Encoding = Encoding.UTF8
.OmitXmlDeclaration = OmitXMLDecl
.Indent = True
.NewLineChars = Environment.NewLine
.NewLineOnAttributes = False
.ConformanceLevel = Xml.ConformanceLevel.Auto
.CheckCharacters = False
End With
Try
'create the xmlwriter object that will write the file out
Dim xw As System.Xml.XmlWriter = Xml.XmlWriter.Create(FileName, xSettings)
'create the xmlserializer that will serialize the object to XML
Dim writer As New XmlSerializer(objType)
'now write it out
writer.Serialize(xw, DataToSerialize, nsBlank)
'be sure to close it or it will remain open
xw.Close()
Return True
Catch ex As Exception
MsgBox(ex.Message)
Return False
End Try
Any clues as to what I need to do?
Comment