Here you can find the source of getFirstElementWithTagName(Node node, String element)
Parameter | Description |
---|---|
node | The node to search |
element | The element tag name to search for |
public synchronized static Node getFirstElementWithTagName(Node node, String element)
//package com.java2s; import org.w3c.dom.*; public class Main { /**//from w w w . j a va 2 s . c o m * Returns the first child element found with the specified tag name * @param node The node to search * @param element The element tag name to search for * @return The matching element Node */ public synchronized static Node getFirstElementWithTagName(Node node, String element) { if (node != null && element != null) { NodeList nl = node.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node n = nl.item(i); if (n.getNodeType() == Node.ELEMENT_NODE && n.getNodeName().equals(element)) return n; } } return null; } }