I want to serialize a class to a string (who is a property of another class). I do it like this:
(schema is the XML I want to put in the string.)
Dim ser As New XmlSerializer(GetType(schemaobject))
Dim sw As New IO.StringWriter()
ser.Serialize(sw, schema)
sw.ToString will give the xml, and I can write:
Dim objReader As System.IO.StreamWriter
objReader = New StreamWriter("C:\xmlfile.txt")
objReader.Write(sw.ToString)
objReader.Close()
But I don't want to write the xml to file I want it stored in a string variable, and I need to put the whole xml inside a CDATA block, how can I do that? I will put sw.ToString (that is my xml) inside a CDATA block and then store my xml inside the CDATA in a string.
How can I do that in VB.NET?
Thanks.
Lise
Suthish NairPosted Apr 8, 2011, 10:58 AM
Karthikeyan AnbarasanPosted Apr 8, 2011, 2:00 AM
Karthikeyan AnbarasanPosted Apr 8, 2011, 1:59 AM
LisePosted Apr 5, 2011, 2:49 AM
I have auto generated a class from an xsd schema. I use auto generated class to generate my xml document. I want my xml document as a string because I want to put it in a variable, not write it to a file. My string variable will be a property of another class, and the object of this class will be sent to a webservice.
My xml document must look like this:
Don't forget me this weekend!
]]>
Don't forget me this weekend!
Suthish NairPosted Apr 4, 2011, 1:17 PM