SKhan
SKhan

Reputation: 11

C# multiple writeattributestring to xml not showing in correct order

            xtw.WriteStartElement("cXML");                               
            xtw.WriteAttributeString("payloadID", payloadidstr);
            xtw.WriteAttributeString("timestamp", utctime());
            xtw.WriteAttributeString("version", "1.2.024");

above code working fine to generate xml attribute. if open xml file in notepad shows the following string which is correct.

cXML payloadID="[email protected]" timestamp="2014-02-14T12:13:39-08:00" version="1.2.024"

but when open xml file in any browser the attribute order is changed showing like this.

cXML version="1.2.024" timestamp="2015-01-15T16:54:48-08:00" payloadID="[email protected]"

Can someone let me know why browser not showing in correct order or how to shows multiple string under one element.

Upvotes: 0

Views: 281

Answers (1)

Alexei Levenkov
Alexei Levenkov

Reputation: 100527

XML does not define ordering of attributes, so there is no "correct" order - compliant reader/writers are free to order the way they pleased.

Per the spec section 3.1:

the order of attribute specifications in a start-tag or empty-element tag is not significant

Upvotes: 2

Related Questions