Here you can find the source of printAttrs(Element elem, String endient, PrintStream pstrm)
static private void printAttrs(Element elem, String endient, PrintStream pstrm)
//package com.java2s; /* it under the terms of the GNU General Public License as published by */ import org.w3c.dom.Element; import org.w3c.dom.Attr; import org.w3c.dom.NamedNodeMap; import java.io.PrintStream; public class Main { static private final String ELEM_ENDIENT = "\t"; static private void printAttrs(Element elem, String endient, PrintStream pstrm) {/*from w w w.j a v a 2 s .c o m*/ NamedNodeMap attrs = elem.getAttributes(); if (attrs.getLength() == 0) { pstrm.print(">"); return; } Attr attr = (Attr) attrs.item(0); if (attrs.getLength() == 1) { pstrm.print(" " + attr.getName() + "=\"" + attr.getValue() + "\">"); return; } endient += ELEM_ENDIENT; for (int i = 0; i < attrs.getLength(); i++) { attr = (Attr) attrs.item(i); pstrm.print("\n" + endient + attr.getName() + "=\"" + attr.getValue() + "\""); } pstrm.print(">"); } }