I'm writing a Collada EXPOTER using serializable classes in conjunction with
the XmlSerializer so please do not post answers about XmlDocument.
Here is my class header:
[Serializable]
[XmlRoot(ElementName = "COLLADA", IsNullable = false)]
public class DaeModel
{
private const string DefaultNamespace = @"http://www.collada.org/2005/11/COLLADASchema";
private string _version = "1.4.1";
[XmlAttributeAttribute(AttributeName = "version", Namespace = DefaultNamespace)]
public string Version
{
get { return _version; }
set { _version = value; }
}
[font=Courier New]I would like to achieve this:[/font]
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
But C# gives me this:
<COLLADA version="1.4.1" xmlns="http://www.collada.org/2005/11/COLLADASchema">
Why is the version in front of the namespace?! How can I put the version behind the xmlns?
Here is my save code:
public void Save(string fileName)
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.Encoding = Encoding.UTF8;
settings.OmitXmlDeclaration = false;
XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
namespaces.Add(string.Empty, DefaultNamespace);
XmlWriter writer = XmlWriter.Create(Console.Out, settings);
XmlSerializer serializer = new XmlSerializer(GetType(), DefaultNamespace);
serializer.Serialize(writer, this, namespaces);
}
Thank you in advance!