List of usage examples for org.w3c.dom Element getChildNodes
public NodeList getChildNodes();
NodeList
that contains all children of this node. From source file:Main.java
public static String getElementValue(Element element) { return element.getChildNodes().item(0).getNodeValue(); }
From source file:Main.java
public static NodeList getNodeList(Element parent) { return parent.getChildNodes(); }
From source file:Main.java
public static void removeAllChildren(Element deps) { NodeList childNodes = deps.getChildNodes(); for (int i = childNodes.getLength() - 1; i >= 0; i--) { Node item = childNodes.item(i); deps.removeChild(item);/*from w ww . j av a 2s .co m*/ } }
From source file:Main.java
public static List<Element> getChildElements(Element ele) { NodeList nl = ele.getChildNodes(); List<Element> childEles = new ArrayList<Element>(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i);// ww w . j a v a 2s . c o m if (node instanceof Element) { childEles.add((Element) node); } } return childEles; }
From source file:Main.java
public static void reduceChildrenListRecursive(Element elem) { for (int i = 0; i < elem.getChildNodes().getLength();) { Node node = elem.getChildNodes().item(i); if (node instanceof Element) { reduceChildrenListRecursive((Element) node); ++i;/*from w w w. j a v a 2s .c om*/ } else { elem.removeChild(node); } } }
From source file:Main.java
public static List getChildElements(Element ele) { NodeList nl = ele.getChildNodes(); List childEles = new ArrayList(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i);//from w ww . j ava2 s. c o m if (node instanceof Element) { childEles.add(node); } } return childEles; }
From source file:Main.java
public static String getValue(Element element) { NodeList l = element.getChildNodes(); StringBuffer s = new StringBuffer(); for (int i = 0; i < l.getLength(); i++) { switch (l.item(i).getNodeType()) { case Node.TEXT_NODE: case Node.CDATA_SECTION_NODE: s.append(l.item(i).getNodeValue()); }//from w ww. ja v a2s . c o m } return s.toString(); }
From source file:Main.java
public static List<Element> getElementChildren(Element root) { NodeList list = root.getChildNodes(); List<Element> children = new ArrayList<Element>(); for (int i = 0; i < list.getLength(); i++) { Node child = list.item(i); if (child instanceof Element) children.add((Element) child); }/*from w w w .j a v a 2 s. c om*/ return children; }
From source file:Main.java
public static final String getData(Node node) { Element e = (Element) node; NodeList childNodes = e.getChildNodes(); Text text = (Text) childNodes.item(0); return (text != null) ? text.getData() : ""; }
From source file:Main.java
public static String getText(Element e) { NodeList nl = e.getChildNodes(); int max = nl.getLength(); for (int i = 0; i < max; i++) { Node n = nl.item(i);//from www .j a v a2 s.c o m if (n.getNodeType() == Node.TEXT_NODE) { return n.getNodeValue(); } } return ""; }