首页 > 代码库 > Element节点输出到System.out

Element节点输出到System.out

1     protected void writeElementToFile(Element valrespEle)  {2         3         try {4             TransformerFactory transformerFactory = TransformerFactory.newInstance();5             Transformer transformer = transformerFactory.newTransformer();    6             transformer.transform(new DOMSource(valrespEle), new StreamResult(System.out));
          //写入文件,
new StreamResult("src/test.xml")
7       } catch (Exception e) { 
8     }
9   }

 

Element节点输出到System.out