Build a QName from the element name
import javax.xml.namespace.QName;
import org.w3c.dom.Element;
public class Utils {
/**
* Build a QName from the element name
* @param el
* @return
*/
public static QName getQName(Element el) {
if (el == null) {
return null;
} else if (el.getPrefix() != null) {
return new QName(el.getNamespaceURI(), el.getLocalName(), el.getPrefix());
} else {
return new QName(el.getNamespaceURI(), el.getLocalName());
}
}
}
Related examples in the same category