0

In javascript can I specify the order of attributes of XMLSerializer output. This is my code.

var serializer = new XMLSerializer ();
var str = serializer.serializeToString (document);

When I try to write this 'str' value to Window.document and again serialize it, I get attributes in different orders.

For example: In first serialize output
<img style="width: 10%" src="../Koala.jpg" />
In second serialize output
<img src="../Koala.jpg" style="width: 10%" />

I want both this outputs to be equal. Since I want to do a string comparison this is an essential requirement. Pls suggest me a way to get this done.. Thank in advance..

user1408470
  • 1,475
  • 3
  • 15
  • 21
  • this article will help you. http://stackoverflow.com/questions/3373529/controlling-order-of-serialization-in-c-sharp –  Jul 18 '12 at 07:59
  • String comparison for XML code is not a good tool for the job. Use [tag:xpath]. Order of attributes in XML is irrelevant. – Tomasz Nurkiewicz Jul 18 '12 at 08:08

0 Answers0