Sort xml attributes for pretty print using javax.xml.transform.Transformer
问题 Is there a way I could tell the xml transformer to sort alphabetically all the attributes for the tags of a given XML? So lets say... <MyTag paramter1="lol" andTheOtherThing="potato"/> Would turn into <MyTag andTheOtherThing="potato" paramter1="lol"/> I saw how to format it from the examples I found here and here, but sorting the tag attributes would be the last issue I have. I was hoping there was something like: transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer