Java examples for XML:XML Node
get First XML Node By Name
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Node getFirstNodeByName(Node root, String tagName) { NodeList nodes;//from w ww .j a v a2 s . c o m nodes = root.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node n = nodes.item(i); if (n.getNodeName().equals(tagName)) { return n; } } return null; } }