Java Code Examples for org.w3c.dom.Document#PROCESSING_INSTRUCTION_NODE

The following examples show how to use org.w3c.dom.Document#PROCESSING_INSTRUCTION_NODE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PXDOMStyleAdapter.java    From pixate-freestyle-android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the children of the given node. In case 'onlyElements' is passed,
 * only the ELEMENT_NODEs will be returned.
 * 
 * @param node
 * @param onlyElements
 * @return
 */
private List<Object> getElementChildren(Node node, boolean onlyElements) {
    NodeList childNodes = node.getChildNodes();
    if (childNodes == null) {
        return Collections.emptyList();
    }
    List<Object> children = new ArrayList<Object>(childNodes.getLength());
    for (int i = 0; i < childNodes.getLength(); i++) {
        short nodeType = childNodes.item(i).getNodeType();
        if (!onlyElements
                || (onlyElements && nodeType != Document.COMMENT_NODE && nodeType != Document.PROCESSING_INSTRUCTION_NODE)) {
            children.add(childNodes.item(i));
        }
    }
    return children;
}