Java examples for XML:DOM Node
Get First Expression XML Child
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { static public Node GetFirstExprChild(Node targetNode) throws Exception { NodeList ChildNodeList = targetNode.getChildNodes(); for (int i = 0; i < ChildNodeList.getLength(); i++) { Node currentNode = ChildNodeList.item(i); // Search for expression node if (currentNode.getNodeName().equals("node:Scalar_String") || currentNode.getNodeName().equals( "node:Expr_Variable") || currentNode.getNodeName().equals( "node:Expr_BinaryOp_Equal") || currentNode.getNodeName().equals( "node:Expr_ArrayDimFetch")) { return currentNode; }//from w w w. j a v a 2 s.c o m } throw new Exception("Target node doesn't contain expr"); } }