Here you can find the source of GetOuterXml(Node node)
Parameter | Description |
---|---|
node | a parameter |
Parameter | Description |
---|---|
TransformerConfigurationException | an exception |
TransformerException | an exception |
public static String GetOuterXml(Node node) throws TransformerConfigurationException, TransformerException
//package com.java2s; //License from project: Open Source License import java.io.StringWriter; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Node; public class Main { /**// w ww. j a va2 s . com * Gets the outerXML from a Node * @param node * @return String - the outer XML * @throws TransformerConfigurationException * @throws TransformerException */ public static String GetOuterXml(Node node) throws TransformerConfigurationException, TransformerException { Transformer transformer = TransformerFactory.newInstance() .newTransformer(); transformer.setOutputProperty("omit-xml-declaration", "yes"); StringWriter writer = new StringWriter(); transformer .transform(new DOMSource(node), new StreamResult(writer)); return writer.toString(); } }