Example #1
0
  @Override
  public Element getElementById(final String id) {

    DOMNodeList results = new DOMNodeList();

    collectNodesByPredicate(
        this,
        results,
        new Predicate<Node>() {

          @Override
          public boolean accept(Node obj) {

            if (obj instanceof DOMElement) {

              DOMElement elem = (DOMElement) obj;

              if (id.equals(elem.getProperty(DOMElement._id))) {
                return true;
              }
            }

            return false;
          }
        },
        0,
        true);

    // return first result
    if (results.getLength() == 1) {
      return (DOMElement) results.item(0);
    }

    return null;
  }
Example #2
0
  @Override
  public NodeList getChildNodes() {

    DOMNodeList _children = new DOMNodeList();

    _children.add(docTypeNode);
    _children.addAll(super.getChildNodes());

    return _children;
  }