Stepan Yakovenko
Stepan Yakovenko

Reputation: 9226

Sort xml attributes alphabetically

I'd like

<node a="2" d="1" c="2"> 

to be converted to

<node a="2" c="2" d="1">

Can you propose some solution with less effort?

Upvotes: 0

Views: 2092

Answers (1)

Michael Kay
Michael Kay

Reputation: 163645

Use an XML canonicalization library. XML canonical form requires the attributes to be in alphabetical order (so that two documents can be compared for equivalence by comparing them at the byte level).

Upvotes: 3

Related Questions