List of usage examples for org.w3c.dom Element getLocalName
public String getLocalName();
From source file:Main.java
public static boolean isLocalName(Element element, String name) { return element.getLocalName().equals(name); }
From source file:Utils.java
public static Element getFirstChild(Element e, String local) { for (Node n = e.getFirstChild(); n != null; n = n.getNextSibling()) { if (n.getNodeType() == Node.ELEMENT_NODE) { Element c = (Element) n; if (c.getLocalName().equals(local)) return c; }//from w w w . j a v a2 s. c om } return null; }
From source file:Utils.java
public static QName getElementQName(Element el) { return new QName(el.getNamespaceURI(), el.getLocalName()); }
From source file:Main.java
public static Element getChildElement(Element parent, String childName, String childNamespace) { NodeList ns = parent.getChildNodes(); for (int i = 0; i < ns.getLength(); i++) { Node n = ns.item(i);//from w w w . j a v a 2 s.c o m if (n instanceof Element) { Element child = (Element) n; if (childName.equals(child.getLocalName()) && childNamespace.equals(child.getNamespaceURI())) { return child; } } } return null; }
From source file:Main.java
public static boolean hasNamedChild(Element e, String name) { Element c = getFirstChild(e); while (c != null && !name.equals(c.getLocalName()) && !name.equals(c.getNodeName())) c = getNextSibling(c);/*from ww w . j a v a 2s. com*/ return c != null; }
From source file:Main.java
public static Element getNamedChild(Element e, String name) { Element c = getFirstChild(e); while (c != null && !name.equals(c.getLocalName()) && !name.equals(c.getNodeName())) c = getNextSibling(c);//from www. j a v a 2s . c om return c; }
From source file:Main.java
static Element findChild(Element element, String ns, String tag) { final NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { if (childNodes.item(i) instanceof Element) { Element child = (Element) childNodes.item(i); if (child.getLocalName().equals(tag) && (ns == null || child.getNamespaceURI().equals(ns))) { return child; }//from w ww . j a v a2 s .com } } return null; }
From source file:Main.java
private static void collectPaths(String path, Hashtable<String, String> allPaths, Element el) { String newPath = path + el.getLocalName() + "/"; allPaths.put(newPath, "1"); for (Iterator<Element> it = childElements(el).iterator(); it.hasNext();) collectPaths(newPath, allPaths, it.next()); }
From source file:Main.java
private static String getLocalName(Element elem) { return (elem.getNamespaceURI() == null) ? elem.getTagName() : elem.getLocalName(); }
From source file:Main.java
/** * An Iterable for the Element's childs, with a particular name, of a node * // ww w . j a va2 s. c o m * @param n * the node get the children from * @param elementName * the name of the child elements * @return An Iterable for the Element's children, with a particular name, of a node */ public static List<Element> elements(Element n, String elementName) { // NodeList subNodes = n.getElementsByTagName(elementName); NodeList subNodes = n.getChildNodes(); int sz = subNodes.getLength(); ArrayList<Element> elements = new ArrayList<Element>(sz); for (int idx = 0; idx < sz; idx++) { Node node = subNodes.item(idx); if (node instanceof Element) { Element el = (Element) node; if (el.getLocalName().equals(elementName)) elements.add((Element) node); } } return elements; }