我有以下序列化方法:
Private Function SerializeData(ByVal data As cData) As String If data IsNot Nothing Then Dim xml_stream As New MemoryStream() Dim sr As StreamReader Dim xs As New XmlSerializer(GetType(cData)) xml_stream = New MemoryStream() Try xs.Serialize(xml_stream, data) xml_stream.Position = 0 sr = New StreamReader(xml_stream) Return sr.ReadToEnd() Finally If sr IsNot Nothing Then sr.Close() xml_stream.Close() End Try Else Return "No data" End If End Function
但是它返回xml嵌套元素的缩进.有没有办法在序列化程序上关闭它,或者我是否需要运行一个find replace例程来摆脱它?
基本上,我想看到的是:
data data
Kevin Dente.. 10
使用接受XmlWriter参数的Serialize重写.使用XmlWriter :: Create创建XmlWriter,传入一个将Indent属性设置为false的XmlWriterSettings对象.
使用接受XmlWriter参数的Serialize重写.使用XmlWriter :: Create创建XmlWriter,传入一个将Indent属性设置为false的XmlWriterSettings对象.