Here you can find the source of printPI(Document doc, PrintStream pstrm)
static private void printPI(Document doc, PrintStream pstrm)
//package com.java2s; /* it under the terms of the GNU General Public License as published by */ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Document; import org.w3c.dom.ProcessingInstruction; import java.io.PrintStream; public class Main { static private void printPI(Document doc, PrintStream pstrm) { NodeList nodes = doc.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node instanceof ProcessingInstruction) { ProcessingInstruction pi = (ProcessingInstruction) node; pstrm.println("<?" + pi.getTarget() + " " + pi.getData() + "?>"); }// w w w. j av a2 s . c o m } } }