![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | XmlSerializer problem - help? Hi everyone, I have a question about XmlSerializer. I have some code that serializes an object to xml, but it has all the whitespace and new lines in the output. How do i remove these? Thanks in advance. Public Shared Function Serialize(ByVal options As OptionsData) As String Try Dim loSerializer As Xml.Serialization.XmlSerializer Dim loStringWriter As System.IO.StringWriter Dim lsResult As String = String.Empty If Not options Is Nothing Then loSerializer = New Xml.Serialization.XmlSerializer(options.GetType) loSerializer.Serialize() loStringWriter = New System.IO.StringWriter() loSerializer.Serialize(loStringWriter, options) loStringWriter.Flush() lsResult = loStringWriter.ToString loStringWriter.Close() End If Return lsResult Catch ex As Exception Throw ex End Try End Function |
My System Specs![]() |
| | #2 (permalink) |
| | Re: XmlSerializer problem - help? Well, i've worked it out :-) but i have another question, i don't want to use any namespaces. I have set the Namespaces = false on the xmlwriter, but it throws an exception that it can't apply namespaces while it is false... Any ideas? Public Shared Function Serialize(ByVal options As SchedulingDefinitionOptionsData) As String Dim lsResult As String = String.Empty Dim loSerializer As Xml.Serialization.XmlSerializer = Nothing Dim loStringWriter As System.IO.StringWriter = Nothing Dim loXmlWriter As Xml.XmlTextWriter = Nothing If options Is Nothing Then Return lsResult Try loSerializer = New Xml.Serialization.XmlSerializer(options.GetType) loStringWriter = New System.IO.StringWriter() loXmlWriter = New Xml.XmlTextWriter(loStringWriter) loXmlWriter.Formatting = Xml.Formatting.None loXmlWriter.Namespaces = False loSerializer.Serialize(loXmlWriter, options) lsResult = loStringWriter.ToString Catch ex As Exception Throw ex Finally If loStringWriter IsNot Nothing Then loStringWriter.Close() End Try Return lsResult End Function |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| the problem with ndis.sys Blue Screen of Death problem solved? | Vista General | |||
| Re: Windows Mail Attachement Problem and Adobe Player Problem with IE8 | Vista mail | |||
| XmlSerializer FileNotFoundException | .NET General | |||
| Generic McAfee Problem Message in Vista Problem Reports | Vista performance & maintenance | |||
| Vista Upgrade Problem - Windows Explorer Loop problem | Vista installation & setup | |||