I can't think of anything to create nodes outside the scope of the object you're serializing.
You can always manually insert it into your XML output stream: <UntestedCode> public static void DoIt( TestClass obj ) { XmlTextWriter writer = new XmlTextWriter( "file.xml", Encoding.UTF8 ); XmlSerializer ser = new XmlSerializer( typeof(TestClass) ); writer.WriteStartDocument(); writer.WriteStartElement( "", "ANOTHERNODE", "" ); ser.Serialize( writer, obj ); writer.Close(); } </UntestedCode> HTH, Christoph Schittko Software Architect MSHOW.com - Web Conferencing and Interactive Broadcasting ----- Original Message ----- From: "Brian Weeres" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 02, 2002 3:51 PM Subject: [DOTNET] XmlSerializer - how to add an extra element to the xml I am trying to add an additional element in my xml when serializing a class using XmlSerializer but I cannot figure out how to do it. Here is my class. public class TestClass { public TestClass() { } [XmlAttributeAttribute] public string ClassID = "123"; public string Name = "Bob"; public int Language = 1; } Here is my ouput <?xml version="1.0" encoding="utf-16"?> <TestClass ClassID="123""> <Name>Bob</Name> <Language>1</Language> </TestClass>" Here is what I want: <?xml version="1.0" encoding="utf-16"?> <ANOTHERNODE> <TestClass ClassID="123""> <Name>Bob</Name> <Language>1</Language> </TestClass>" </ANOTHERNODE> How can I add "ANOTHERNODE"? I can accomplish this if I create another class that has a member variable of TestClass and serialize that class but I would like to do it just using TestClass if possible. Thanks for any help. Brian Brian ---------------------------------------- Brian Weeres Protegra Technology Group www.protegra.com Unit 2-55 Henlow Bay, Winnipeg MB R3Y 1G4 General: (204) 956-2727 Direct: (204) 487-5654 Fax: (204) 477-9421 You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.