Java XML NodeList getFirstNodeValue(NodeList nodeList)

Here you can find the source of getFirstNodeValue(NodeList nodeList)

Description

get First Node Value

License

Open Source License

Declaration

public static String getFirstNodeValue(NodeList nodeList) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static String getFirstNodeValue(NodeList nodeList) {
        String nodeValue = "";
        StringBuffer varBuffer = new StringBuffer();
        Node node = (Node) nodeList.item(0);
        if (node != null) {
            /*if(node != null) {
               Node eleText = node.getFirstChild();
              if(eleText != null) {/*from   w w  w  . j  a  v  a  2  s . co  m*/
              nodeValue = eleText.getNodeValue();
              }
            }*/
            NodeList childNodes = node.getChildNodes();
            for (int i = 0; i < childNodes.getLength(); i++) {
                varBuffer.append(childNodes.item(i).getNodeValue().toString());
            }
        }
        nodeValue = varBuffer.toString();
        return nodeValue;

    }
}

Related

  1. getFirstElement(NodeList list)
  2. getFirstElement(NodeList list)
  3. getFirstElement(NodeList nodes)
  4. GetFirstInstance(NodeList nList)
  5. getFirstNode(NodeList nodeList)
  6. getFirstTextValueFromNodeList(NodeList nList)
  7. getFirstValue(NodeList nodes)
  8. getMetaScriptType(List metaNodeList)
  9. getMethodNames(NodeList methodNodes)