Here you can find the source of printElementStart(Element elem, StringWriter sw)
Parameter | Description |
---|---|
elem | the element in question |
static void printElementStart(Element elem, StringWriter sw)
//package com.java2s; //License from project: Open Source License import java.io.StringWriter; import org.w3c.dom.Node; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; public class Main { /**// w w w . j av a2 s . c om * Print a single element node to the current buffer * @param elem the element in question */ static void printElementStart(Element elem, StringWriter sw) { sw.write("<"); sw.write(elem.getNodeName()); NamedNodeMap attrs = elem.getAttributes(); for (int j = 0; j < attrs.getLength(); j++) { Node attr = attrs.item(j); sw.write(" "); sw.write(attr.getNodeName()); sw.write("=\""); sw.write(attr.getNodeValue()); sw.write("\""); } if (elem.getFirstChild() == null) sw.write("/>"); else sw.write(">"); } }