Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

XmlElement has an "Order" attribute which you can use to specify the precise order of your properties (in relation to each other anyway) when serializing using XmlSerializer.

public class bookingList
{
    [XmlElement(Order = 1)]
    public string error { get; set; }
    [XmlElement(Order = 2)]
    public int counter { get; set; }
    [XmlElement(ElementName = "booking", Order = 3)]
    public List<booking> bookings = new List<booking>();
}

Is there a similar thing for XmlAttribute? I just want to set the order of the attributes from something like

<MyType end="bob" start="joe" />

to

<MyType start="joe" end="bob" />

This is just for readability, my own benefit really.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.7k views
Welcome To Ask or Share your Answers For Others

1 Answer

You don't, as attributes have no order in XML (section 3.1 of the XML recommendation says: "Note that the order of attribute specifications in a start-tag or empty-element tag is not significant.").


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...