Example usage for org.w3c.dom.html HTMLElement getElementsByTagName

List of usage examples for org.w3c.dom.html HTMLElement getElementsByTagName

Introduction

In this page you can find the example usage for org.w3c.dom.html HTMLElement getElementsByTagName.

Prototype

public NodeList getElementsByTagName(String name);

Source Link

Document

Returns a NodeList of all descendant Elements with a given tag name, in document order.

Usage

From source file:org.fit.cssbox.scriptbox.dom.Html5DocumentImpl.java

/**
 * Returns base element if there is any inside Document.
 * /*from  www  . j a v  a 2  s. c om*/
 * @return Base element if there is any inside Document.
 */
public HTMLBaseElement getBaseElement() {
    // FIXME: We should not wait for completeness, but try to get base address from actual loaded elements - proper synchronized section is needed.
    if (_documentReadiness == DocumentReadyState.COMPLETE) {
        HTMLElement head = getHead();
        NodeList baseElements = head.getElementsByTagName("base");

        if (baseElements.getLength() > 0) {
            Node baseElement = baseElements.item(0);

            if (baseElement instanceof HTMLBaseElement) {
                return (HTMLBaseElement) baseElement;
            }
        }
    }

    return null;
}