Tarren said:
My serialized class is ending up in a XML.XMLTEXTRIDER
I don't know if that's incoming (XmlTextReader) or outgoing
(XmlTextWriter)?
If you are holding an XmlTextReader named ''reader,''
then you can read the XML into a string like this,
Dim xmlStr As String
Dim doc As XmlDocument = New XmlDocument( )
' Uncomment next statement if you care about whitespace.
' doc.PreserveWhitespace = True
doc.Load( reader)
xmlStr = doc.OuterXml
If you are going to hold an XmlTextWriter named ''writer,'' then wrap
it around a System.IO.StringWriter before you start serializing an
object named ''myObject'' to an XmlSerializer named 'serializer'',
Dim xmlStr As String
Dim strWriter As System.IO.StringWriter
strWriter = New System.IO.StringWriter( New System.Text.StringBuilder( ) )
writer = New XmlTextWriter( strWriter )
serializer.Serialize( writer, myObject)
xmlStr = strWriter.ToString( )
How do I read the contents of a stream into a string?
Wrap the Stream in a System.IO.StreamReader and then call
ReadToEnd( ),
Dim streamStr As String
streamStr = New System.IO.StreamReader( stream).ReadToEnd( )
Derek Harmon