Java XML Document Print printPI(Document doc, PrintStream pstrm)

Here you can find the source of printPI(Document doc, PrintStream pstrm)

Description

print PI

License

Open Source License

Declaration

static private void printPI(Document doc, PrintStream pstrm) 

Method Source Code

//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
        }
    }
}

Related

  1. printDocumentToStdout(final Document document)
  2. printDocumentTree(Node el)
  3. printDOM(File file, Document doc, String encoding)
  4. printElements(Document doc)
  5. printElements(Document dom)
  6. printXML(Document doc)
  7. printXml(Document xml, Writer out)
  8. printXmlDocument(Document doc)
  9. printXMLDocument(Document document)