Hi Vlad,
Welcome to MSDN newsgroup.
From your description, when you use the .NET XmlSerizliation to serizliaze
some class instances out to xml stream, you want to also expose the DocType
for the whole xml document, yes?
As for the DOCTYPE, there hasn't buildin XmlSerlization Attributes for
specifying DOCTYPE. In fact, this is because the Xml Serialization is
Class/Element based rather than Document based. As for DOCTYPE, it is
specified for a certain Xml document. Currently I think we can use the
following means to inject the DOCTYPE in our serilization's output document:
When do the serizliation, we use an XmlTextWriter to delegate the
underlying StreamWriter we'll write out the serialized instances. And we
can use the XmlWriter.WriteDocType to inject our custom DocType. For
example:
XmlSerializer serializer = new XmlSerializer(typeof(Group));
Group group = new Group();
StreamWriter sw = new StreamWriter("group.xml");
XmlWriter xw = new XmlTextWriter(sw);
xw.WriteDocType("Group", null, null, "<!ENTITY h 'hardcover'>");
serializer.Serialize(xw,group);
xw.Close();
sw.Close();
HTH. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)