I've been following the solution found on How can I make the xmlserializer only serialize plain xml? in an attempt to only serialize plain text however I'm running into a few problems as I do this on the VB.net side
The aim is to prevent the lines <?xml version="1.0" encoding="utf-16"?>
and attributes xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
from showing
I have a sub as follows:
Private Sub writeXMLContent()
For Each dataItem As dataClass In dataSet
Dim emptyNameSpace As XmlSerializerNamespaces = New XmlSerializerNamespaces({XmlQualifiedName.Empty})
Dim serializer As New XmlSerializer(GetType(dataClass))
Dim settings As New XmlWriterSettings
settings.Indent = True
settings.OmitXmlDeclaration = True
Using stream As New StringWriter
Using writer = XmlWriter.Create(stream, settings)
serializer.Serialize(writer, serializer, emptyNameSpace)
'will write each line to a file here
End Using
End Using
Next
End Sub
however I keep coming across the same two errors:
- The line
Using writer = XmlWriter.Create(stream, settings)
throws an error using operand of type object must implement system.iDisposable - The line
serializer.Serialize(writer, serializer, emptyNameSpace)
seems to not like my second parameter as it expects an object? I'm not too sure what object I would pass here?