Here you can find the source of getElementNamespaces(Element element, Set
Parameter | Description |
---|---|
element | The element to examine. |
namespaces | A set to which new namespace URIs will be added. |
public static void getElementNamespaces(Element element, Set<String> namespaces)
//package com.java2s; //License from project: Common Public License import java.util.Set; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; public class Main { /**/*from w w w . j av a 2 s . c o m*/ * Gets the namespaces declared on the element and adds them to the specified set. * @param element The element to examine. * @param namespaces A set to which new namespace URIs will be added. */ public static void getElementNamespaces(Element element, Set<String> namespaces) { NamedNodeMap atts = element.getAttributes(); for (int i = 0; i < atts.getLength(); i++) { Attr att = (Attr) (atts.item(i)); String prefix = att.getPrefix(); if (prefix != null && prefix.equals("xmlns")) { String nsURI = att.getValue(); namespaces.add(nsURI); } else { if (att.getName().equals("xmlns")) { namespaces.add(att.getValue()); } } } } }