Java XML NodeList getXmlNodeValue(NodeList nodeList)

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

Description

Extract the node string representation.

License

Open Source License

Parameter

Parameter Description
nodeList a parameter

Declaration

public static String getXmlNodeValue(NodeList nodeList) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**//from  ww  w  .  j  av a  2 s. c  o  m
     * Extract the node string representation.
     * 
     * @param nodeList
     * @return
     */
    public static String getXmlNodeValue(NodeList nodeList) {
        String retObj = null;

        if (nodeList != null && nodeList.getLength() > 0) {
            Element element = (Element) nodeList.item(0);
            if (element != null && element.getChildNodes() != null) {
                NodeList childNodes = element.getChildNodes();
                if (childNodes != null && childNodes.getLength() > 0) {
                    retObj = ((Node) childNodes.item(0)).getNodeValue();
                }
            }
        }
        return retObj;
    }
}

Related

  1. getOccurs(String nodeName, NodeList nodes)
  2. getTableIDOfTableAlias(String tableAlias, NodeList referList1, NodeList referList2)
  3. getText(NodeList elem)
  4. getTextContent(NodeList nodeList)
  5. getTextFields(NodeList list)
  6. hasElementNodes(NodeList list)
  7. hasImageNodes(NodeList nodeList)
  8. indexOf(NodeList nodeList, String tagName, int startIdx)
  9. isEmpty(@Nullable final NodeList aNL)