Java XML Element Get from Parent getNodeContents(Node parentNode)

Here you can find the source of getNodeContents(Node parentNode)

Description

get Node Contents

License

Open Source License

Declaration

public static String getNodeContents(Node parentNode) 

Method Source Code

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

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

public class Main {
    public static String getNodeContents(Node parentNode) {
        StringBuilder sb = new StringBuilder();

        NodeList childNodes = parentNode.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node node = childNodes.item(i);
            String nodeValue = node.getNodeValue();
            if (nodeValue != null)
                sb.append(nodeValue);//from www.ja v a 2  s .c om
        }

        return sb.toString();
    }
}

Related

  1. getNameToFirstNode(Node parent, String node_name)
  2. getNameToNodeList(Node parent, String node_name)
  3. getNodeAtPosition(Node parent, int offset)
  4. getNodeBean(Node parent)
  5. getNodeByLocalName(final Node parent, final String name)
  6. getNodeContents(String nodeName, Node parentNode)
  7. getNodeList(Element parent)
  8. getNodes(final Node parent, final String nodeName)