Java XML Node Text Value getNodeText(Node node)

Here you can find the source of getNodeText(Node node)

Description

get Node Text

License

Open Source License

Declaration

public static String getNodeText(Node node) 

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 {
    public static String getNodeText(Node parentNode, String nodeName) {
        Element fstElmnt = (Element) parentNode;
        NodeList fstNmElmntLst = fstElmnt.getElementsByTagName(nodeName);
        Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
        NodeList fstNm = fstNmElmnt.getChildNodes();
        String ret = fstNm.item(0).getNodeValue();
        return ret;
    }/*w  w  w.  j a  v a  2 s .c  o  m*/

    public static String getNodeText(Node node) {
        NodeList fstNm = ((Element) node).getChildNodes();
        String ret = fstNm.item(0).getNodeValue();
        return ret;
    }
}

Related

  1. getNodeText(Node node)
  2. getNodeText(Node node)
  3. getNodeText(Node node)
  4. getNodeText(Node node)
  5. getNodeText(Node node)
  6. getNodeText(Node t)
  7. getNodeText(org.w3c.dom.Node node)
  8. getNodeTextContent(Node node, String node_name)
  9. getNodeTexts(Node node, String... nodePath)