Java XML Node Find findAllProcessingIstructions(Node node, String name, List result)

Here you can find the source of findAllProcessingIstructions(Node node, String name, List result)

Description

find All Processing Istructions

License

Open Source License

Declaration

private static void findAllProcessingIstructions(Node node, String name, List<ProcessingInstruction> result) 

Method Source Code

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

Related

  1. findAllDescendantElements(Node e, String qname, Collection vector)
  2. findAllNodes(Node node, String[] nodeNames, ArrayList results)
  3. findAllNodesRecursive(Node n, String name)
  4. findAllUrisRecursive(Node node, List nodes)
  5. findElement(Node node, String tagName)
  6. findElement(Node startNode, String name, String namespace)
  7. findElementById(Node head, String id)