Return the XML qualified name, that is to say the prefix -if any- with the local name. - Android XML

Android examples for XML:XML Node

Description

Return the XML qualified name, that is to say the prefix -if any- with the local name.

Demo Code


//package com.java2s;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;

public class Main {
    /**/*from   w w w  .j a v a2s.  com*/
     * Return the qualified name, that is to say the prefix -if any- with the
     * local name.
     *
     * @param qName
     *            The QName.
     * @return A string that looks like "<tt>prefix:localName</tt>" or "
     *         <tt>NCName</tt>".
     */
    public static String getQualifiedName(QName qName) {
        if (!XMLConstants.NULL_NS_URI.equals(qName.getNamespaceURI())
                && !XMLConstants.DEFAULT_NS_PREFIX
                        .equals(qName.getPrefix())) {
            return qName.getPrefix() + ":" + qName.getLocalPart();
        } else {
            return qName.getLocalPart();
        }
    }
}

Related Tutorials