Java XML Node Name getTagNameWithoutPrefix(Node node)

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

Description

get Tag Name Without Prefix

License

Open Source License

Declaration

public static String getTagNameWithoutPrefix(Node node) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Red Hat, Inc.//from ww w.j  ava  2  s . c  o  m
 * Distributed under license by Red Hat, Inc. All rights reserved.
 * This program is made available under the terms of the
 * Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Red Hat, Inc. - initial API and implementation
 ******************************************************************************/

import org.w3c.dom.Node;

public class Main {
    public static String getTagNameWithoutPrefix(Node node) {
        if (node == null || node.getNodeName() == null) {
            return null;
        }
        String prefix = node.getPrefix();
        String nodeName = node.getNodeName();
        String resVal = nodeName;
        if ((prefix != null && prefix.trim().length() > 0) || nodeName.indexOf(':') != -1) {
            resVal = nodeName.substring(nodeName.indexOf(':') + 1);
        }
        return resVal;
    }
}

Related

  1. getSubNodes(Node node, String subNodeName)
  2. getSubNodeValue(Node node, String nodeName, String subNodeName)
  3. getTagName(Node labelNode)
  4. getTagName(Node node)
  5. getTagName(Node tag, boolean useJsfcTags)
  6. getTifDimension(Node node, String nodeName)
  7. getUnqualifiedNodeName(org.w3c.dom.Node node)
  8. isMatchNodeName(Node node, String node_name)