I am converting a xml file to string using java My xml is
<GTSRequest command="version"> <Authorization account="account" user="user" password="password"/> </GTSRequest> and Java Code is
public static void main(String[] args) throws IOException { // TODO code application logic here String a = System.getProperty("user.dir") + "/XML/Get Current GTS Version.xml"; System.out.println(convertXMLFileToString(a)); } public static String convertXMLFileToString(String fileName) { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); InputStream inputStream = new FileInputStream(new File(fileName)); org.w3c.dom.Document doc = documentBuilderFactory.newDocumentBuilder().parse(inputStream); StringWriter stw = new StringWriter(); Transformer serializer = TransformerFactory.newInstance().newTransformer(); serializer.transform(new DOMSource(doc), new StreamResult(stw)); return stw.toString(); } catch (Exception e) { e.printStackTrace(); } return null; } but when i am converting XMl to String my out will change which is i am not want . Output is
<?xml version="1.0" encoding="UTF-8" standalone="no"?><GTSRequest command="version"> <Authorization account="account" password="password" user="user"/> </GTSRequest> there is password and user change there place alphabetically
how can i resolve this thanks is advance