可能重复:
Control order of XML attributes in outputed file in Java
我有这段代码:
Element node = testDoc.createElement("image_file");
node.setAttribute("id", count);
node.setAttribute("file_name", fileNameCombinedWithPNG);
我的XML在filename
之前有id
,无论我做什么,即使我切换设置属性的顺序,XML的输出看起来都是一样的,即它是:< / p>
image_file filename="xyz" id="1" as but I want is image_file id="1" filename="adfx"