Here you can find the source of getStringRepresentation(Element element)
Parameter | Description |
---|---|
element | the element to get the string representation for |
public static String getStringRepresentation(Element element)
//package com.java2s; //License from project: LGPL import org.w3c.dom.Element; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSSerializer; public class Main { /**/*from ww w . j a v a 2 s . c o m*/ * Gets the string representation for the given XML element, including tag and attributes. * * @param element the element to get the string representation for * @return the string representation for the given element */ public static String getStringRepresentation(Element element) { DOMImplementationLS implementation = (DOMImplementationLS) element.getOwnerDocument().getImplementation(); LSSerializer lsSerializer = implementation.createLSSerializer(); lsSerializer.getDomConfig().setParameter("xml-declaration", false); return lsSerializer.writeToString(element); } }