Ejemplo n.º 1
0
  /** @return the first child element matching the given name and namespace URI, or null */
  public Element getFirstChildElement(String localName, String nsUri) {
    for (int i = 0; i < getChildCount(); ++i) {
      Node child = getChild(i);
      if (child instanceof Element) {
        Element element = (Element) child;
        if (areEqual(element.getLocalName(), localName)
            && areEqual(element.getNamespaceURI(), nsUri)) {
          return element;
        }
      }
    }

    return null;
  }
Ejemplo n.º 2
0
  /** @return an unmodifiable list of child elements matching the given name and namespace URI */
  public List<Element> getChildElements(String localName, String nsUri) {
    List<Element> elements = newArrayList();
    for (int i = 0; i < getChildCount(); ++i) {
      Node child = getChild(i);
      if (child instanceof Element) {
        Element element = (Element) child;
        if (areEqual(element.getLocalName(), localName)
            && areEqual(element.getNamespaceURI(), nsUri)) {
          elements.add(element);
        }
      }
    }

    return unmodifiableList(elements);
  }