Here you can find the source of findAllProcessingIstructions(Node node, String name, List
private static void findAllProcessingIstructions(Node node, String name, List<ProcessingInstruction> result)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.ProcessingInstruction; public class Main { public static List<ProcessingInstruction> findAllProcessingIstructions(Node node, String name) { List<ProcessingInstruction> result = new ArrayList<ProcessingInstruction>(); findAllProcessingIstructions(node, name, result); return result; }/*w w w . j a v a 2s. co m*/ private static void findAllProcessingIstructions(Node node, String name, List<ProcessingInstruction> result) { NodeList nodeList = node.getChildNodes(); if (nodeList == null) { return; } for (int i = 0; i < nodeList.getLength(); ++i) { Node n = nodeList.item(i); if (n.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { if (name == null || name.length() == 0 || n.getNodeName().equals(name)) { result.add((ProcessingInstruction) n); } } findAllProcessingIstructions(n, name, result); } } }