Here you can find the source of getSubnodesOfType(Node in, int type)
Parameter | Description |
---|---|
in | non-null Node |
type | Some note type constant i.e. Node.CDATA_SECTION_NODE |
public static Node[] getSubnodesOfType(Node in, int type)
//package com.java2s; //License from project: Apache License import org.w3c.dom.*; import java.util.*; public class Main { /**/*from www .j a v a2 s. co m*/ * @param in non-null Node * @param type Some note type constant i.e. Node.CDATA_SECTION_NODE * @return non-null array or children of that type */ public static Node[] getSubnodesOfType(Node in, int type) { NodeList subnodes = in.getChildNodes(); if (subnodes == null) return (new Node[0]); int count = subnodes.getLength(); List holder = new ArrayList(); for (int i = 0; i < count; i++) { Node test = subnodes.item(i); if (test.getNodeType() == type) holder.add(test); } Node[] ret = new Node[holder.size()]; holder.toArray(ret); return (ret); } }