Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <?xml version='1.0' encoding='UTF-8' ?>
  2. <config>
  3. <Connections>
  4. <DbMetaData tablePrefix="example"/>
  5. <Date>inOut</Date>
  6. <AGSConnection
  7. outputDirectory="C:directory2directoriesisoutput"
  8. virtualOutputDirectory="https://directory1.example1.net/ex/rest/output"/>
  9. <SDEConnection
  10. server="srv01"
  11. instance="sde:sqlserver:srv01"
  12. database="DBex"
  13. authenticationMode="DBMS"
  14. user="user1"
  15. password="pass123"
  16. version="sde.DEFAULT"
  17. sdeConnectionPath="C:\tmp\ex\conexion\ser01.sde"/>
  18. </Connections>
  19. </config>
  20.  
  21. File file = new File(fileXML);
  22. DocumentBuilder dBuilder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
  23. doc = dBuilder.parse(file);
  24. XPath xPath = XPathFactory.newInstance().newXPath();
  25. String expression = "/config/Connections/SDEConnnection/server";
  26. NodeList nodes = (NodeList)xPath.evaluate(pathNodo,doc, XPathConstants.NODESET);
  27. for (int idx = 0; idx < nodes.getLength(); idx++) {
  28. Node node = nodes.item(idx);
  29. node.setTextContent(valorNodo);
  30. }
  31. Transformer transformer = TransformerFactory.newInstance().newTransformer();
  32. transformer.transform(new DOMSource(doc), new StreamResult(new File("C:/test.xml")));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement