Java XML Node Name getNodeName(Node node)

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

Description

get Node Name

License

Open Source License

Declaration

private static String getNodeName(Node node) 

Method Source Code

//package com.java2s;
/**************************************************************************************
 * Copyright (C) 2012 Lisa park, Inc. All rights reserved. 
 * http://www.lisa-park.com                           *
 * E-Mail: alexmy@lisa-park.com                                                       *
 * ---------------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the GPL license       *
 * a copy of which has been included with this distribution in the license.txt file.  *
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt                               *
 **************************************************************************************/

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

public class Main {
    private static String getNodeName(Node node) {
        String name = "";
        NodeList nodeList = node.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node curNode = nodeList.item(i);
            if ("name".equalsIgnoreCase(curNode.getNodeName())) {
                name = curNode.getTextContent().replace("\"", "");
                break;
            }/* ww  w. j a va  2  s .  co m*/
        }

        return name;
    }
}

Related

  1. getNodeContent(Node n, String nodename)
  2. getNodeName(Node node)
  3. getNodeName(Node node)
  4. getNodeName(Node node)
  5. getNodeName(Node node)
  6. getNodeNameIgnorePrefix(Node node)
  7. getNodeNames(Set nodes)
  8. getNodeNameWithNamespace(Node node)
  9. getNodes(Node iNode, String iNodeName)