Java XML Element Find findNodeValue(Element firstElement, String name)

Here you can find the source of findNodeValue(Element firstElement, String name)

Description

find Node Value

License

Apache License

Declaration

public static String findNodeValue(Element firstElement, String name) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.*;

public class Main {
    public static String findNodeValue(Element firstElement, String name) {
        String nodeValue = null;//from  w  w w . j a va2  s.  c  om
        NodeList firstNameList = firstElement.getElementsByTagName(name);
        Element firstNameElement = (Element) firstNameList.item(0);

        NodeList textFNList = firstNameElement.getChildNodes();

        if (textFNList.getLength() > 0) {
            nodeValue = (textFNList.item(0)).getNodeValue();
        }
        return nodeValue;
    }
}

Related

  1. findElement(final Element e, final String find)
  2. findElement(final String idValue, final String idTagName, final String tagName, final Element root)
  3. findElementAsString(final Element e, final String find)
  4. findElementWithId(String id, Element root)
  5. findNodesByType(Element topElm, int type)
  6. getAllElements(Element config, String elementName)
  7. getAllElements(Element element)
  8. getAllElements(Node context)
  9. getAllElementsByTagName(Element elem, String name)