Serialize a .net object and omit the doctype?

jay

New Member
I've written some .net code to serialize an object using the XMLSerializer class.\[code\] public static string serialize(object o) { Type type = o.GetType(); System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(type); System.IO.StringWriter writer = new System.IO.StringWriter(); serializer.Serialize(writer, o); return writer.ToString(); }\[/code\]The output looks like this:\[code\]<?xml version="1.0" encoding="utf-16"?><ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <string>a</string> <string>b</string> <string>c</string></ArrayOfString>\[/code\]That's great, but what I would really like is to get just the root node without the XML doctype declaration at the beginning.The reason I want to do this is because I would like to use the root element of the XML serialized object as part of another XML document.
 
Back
Top