Groups | Blog | Home
all groups > dotnet xml > may 2004 >

dotnet xml : Controlling order of serialization



Lidström
5/19/2004 11:18:51 AM
Hello,

how can I control the order of which elements are serialized. For example,
my class looks like:

public __gc class Author {
public:
Author();

// get/set methods

[System::Xml::Serialization::XmlAttributeAttribute("createdBy")]
__property System::String* get_createdBy();
__property void set_createdBy(System::String* s);

[System::Xml::Serialization::XmlAttributeAttribute("createdByEmail")]
__property System::String* get_createdByEmail();
__property void set_createdByEmail(System::String* s);

protected:

// members

System::String* m_createdBy;
System::String* m_createdByEmail;
};

And it is serialized like this:
<Author createdByEmail="someone@microsoft.com" createdBy="LIDA" />
But I would like it to be serialized like this:
<Author createdBy="LIDA" createdByEmail="someone@microsoft.com" />

Thanks!

--
Dino Chiesa [Microsoft]
5/26/2004 4:11:59 PM
[quoted text, click to view]

But really you are asking about the order of ATTRIBUTES, not ELEMENTS.

The order of attributes is not semantically important in XML Schema.

I don't believe this is "officially" controllable from the documented XML
Serialization interfaces (APIs and inline code attributes)

-Dino



[quoted text, click to view]

AddThis Social Bookmark Button