com.aspose.html.dom

Class Document

    • Field Detail

      • strCDataSectionName

        public final String strCDataSectionName
      • strCommentName

        public final String strCommentName
      • strDocumentFragmentName

        public final String strDocumentFragmentName
      • strDocumentName

        public final String strDocumentName
      • strEmpty

        public String strEmpty
      • strEntityName

        public final String strEntityName
      • strTextName

        public final String strTextName
      • strReservedXml

        public String strReservedXml
      • strReservedXmlns

        public String strReservedXmlns
      • strReservedXhtmlns

        public String strReservedXhtmlns
      • strSignificantWhitespaceName

        public String strSignificantWhitespaceName
      • strSpace

        public String strSpace
      • strXml

        public String strXml
      • strXmlns

        public String strXmlns
    • Constructor Detail

      • Document

        public Document(IBrowsingContext context)

        Initializes a new instance of the Document class.

        Parameters:
        context - The browsing context.
    • Method Detail

      • getNameTable

        public com.aspose.ms.System.Xml.XmlNameTable getNameTable()

        Gets the System.Xml.XmlNameTable associated with this implementation.

      • getContext

        public IBrowsingContext getContext()

        Gets the current browsing context.

        Value: The context.
      • getLocation

        public Location getLocation()

        The location of the document.

        Value: The location.
      • getDocumentURI

        @DOMNameAttribute(name="documentURI")
        public String getDocumentURI()

        The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument.

        Value: The document URI.
      • getBaseURI

        public String getBaseURI()

        The absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI.

        Overrides:
        getBaseURI in class Node
      • getNodeName

        public String getNodeName()

        The name of this node, depending on its type.

        Value: The name of the node.
        Specified by:
        getNodeName in class Node
      • getNodeType

        public int getNodeType()

        A code representing the type of the underlying object.

        Value: The type of the node.
        Specified by:
        getNodeType in class Node
      • getQuirksMode

        public byte getQuirksMode()
      • setQuirksMode

        public void setQuirksMode(byte value)
      • getCharacterSet

        @DOMNameAttribute(name="characterSet")
        public String getCharacterSet()

        Gets the document's encoding.

        Value: The document's encoding.
      • getCharset

        @DOMNameAttribute(name="charset")
        public String getCharset()

        Gets the document's encoding.

        Value: The document's encoding.
      • getInputEncoding

        @DOMNameAttribute(name="inputEncoding")
        public String getInputEncoding()

        Gets the document's encoding.

        Value: The document's encoding.
      • getContentType

        @DOMNameAttribute(name="contentType")
        public String getContentType()

        Gets the document content type.

        Value: The type of the content.
      • getMimeType

        public MimeType getMimeType()
      • getDocumentElement

        @DOMNameAttribute(name="documentElement")
        public Element getDocumentElement()

        This is a convenience attribute that allows direct access to the child node that is the document element of the document.

        Value: The document element.
      • createElement

        @DOMNameAttribute(name="createElement")
        public Element createElement(String localName)

        Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.

        Parameters:
        localName - Name of the tag.
        Returns:
        The Element.
      • createElementNS

        @DOMNameAttribute(name="createElementNS")
        public Element createElementNS(String namespaceURI,
                                                                                  String qualifiedName)

        Creates an element of the given qualified name and namespace URI.

        Parameters:
        namespaceURI - The namespace URI.
        qualifiedName - Name of the qualified.
        Returns:
        The Element.
      • createDocumentFragment

        @DOMNameAttribute(name="createDocumentFragment")
        public DocumentFragment createDocumentFragment()

        Creates an empty DocumentFragment object.

        Returns:
        The DocumentFragment.
      • createTextNode

        @DOMNameAttribute(name="createTextNode")
        public Text createTextNode(String data)

        Creates a Text node given the specified string.

        Parameters:
        data - The text data.
        Returns:
        The Text.
      • createComment

        @DOMNameAttribute(name="createComment")
        public Comment createComment(String data)

        Creates a Comment node given the specified string.

        Parameters:
        data - The comment data.
        Returns:
        The Comment.
      • createCDATASection

        @DOMNameAttribute(name="createCDATASection")
        public CDATASection createCDATASection(String data)

        Creates a CDATASection node whose value is the specified string.

        Parameters:
        data - The CDATA data.
        Returns:
        The CDATASection.
      • createProcessingInstruction

        @DOMNameAttribute(name="createProcessingInstruction")
        public ProcessingInstruction createProcessingInstruction(String target,
                                                                                                                        String data)

        Creates a ProcessingInstruction node given the specified name and data strings.

        Parameters:
        target - The target.
        data - The instruction data.
        Returns:
        The ProcessingInstruction.
      • createAttribute

        @DOMNameAttribute(name="createAttribute")
        public Attr createAttribute(String localName)

        Creates an Attr of the given name.

        Parameters:
        localName - The attribute name.
        Returns:
        The Attr.
      • createAttributeNS

        @DOMNameAttribute(name="createAttributeNS")
        public Attr createAttributeNS(String namespaceURI,
                                                                                   String qualifiedName)

        Creates an attribute of the given qualified name and namespace URI.

        Parameters:
        namespaceURI - The namespace URI.
        qualifiedName - Name of the qualified.
        Returns:
        The Attr.
      • createAttribute

        public Attr createAttribute(DOMName name)
      • createEntityReference

        @DOMNameAttribute(name="createEntityReference")
        public EntityReference createEntityReference(String name)

        Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.

        Parameters:
        name - The entity name.
        Returns:
        The EntityReference.
      • createDocumentType

        @DOMNameAttribute(name="createDocumentType")
        public DocumentType createDocumentType(String name,
                                                                                             String publicId,
                                                                                             String systemId,
                                                                                             String internalSubset)

        Creates a DocumentType node.

        Parameters:
        name - The document type name.
        publicId - The public id.
        systemId - The system id.
        internalSubset - The internal subset.
        Returns:
        The DocumentType.
      • getElementsByTagName

        @DOMNameAttribute(name="getElementsByTagName")
        public HTMLCollection getElementsByTagName(String tagname)

        Returns a NodeList of all the Elements in document order with a given tag name and are contained in the document.

        Parameters:
        tagname - The tagname.
        Returns:
        Returns nodes.
      • getElementsByTagNameNS

        @DOMNameAttribute(name="getElementsByTagNameNS")
        public HTMLCollection getElementsByTagNameNS(String namespaceURI,
                                                                                                       String localName)

        Returns a NodeList of all the Elements with a given local name and namespace URI in document order.

        Parameters:
        namespaceURI - The namespace URI.
        localName - Name of the local.
        Returns:
        Returns nodes
      • getElementById

        @DOMNameAttribute(name="getElementById")
        public Element getElementById(String elementId)

        Returns the Element that has an ID attribute with the given value. If no such element exists, this returns null. If more than one element has an ID attribute with that value, what is returned is undefined.

        Parameters:
        elementId - The element id.
        Returns:
        The Element.
      • createNodeIterator

        public INodeIterator createNodeIterator(Node root,
                                                long whatToShow,
                                                INodeFilter filter)

        Create a new NodeIterator over the subtree rooted at the specified node.

        Specified by:
        createNodeIterator in interface IDocumentTraversal
        Parameters:
        root - node which will be iterated together with its children. The iterator is initially positioned just before this node. The whatToShow flags and the filter, if any, are not considered when setting this position. The root must not be null.
        whatToShow - flag specifies which node types may appear in the logical view of the tree presented by the iterator. See the description of NodeFilter for the set of possible SHOW_ values.These flags can be combined using OR.
        filter - NodeFilter to be used with this TreeWalker, or null to indicate no filter.
        Returns:
        The newly created NodeIterator.
        Throws:
        DOMException - NOT_SUPPORTED_ERR: Raised if the specified root is null.
      • createTreeWalker

        public ITreeWalker createTreeWalker(Node root,
                                            long whatToShow,
                                            INodeFilter filter)

        Create a new TreeWalker over the subtree rooted at the specified node.

        Specified by:
        createTreeWalker in interface IDocumentTraversal
        Parameters:
        root - node which will serve as the root for the TreeWalker. The whatToShow flags and the NodeFilter are not considered when setting this value; any node type will be accepted as the root. The currentNode of the TreeWalker is initialized to this node, whether or not it is visible. The root functions as a stopping point for traversal methods that look upward in the document structure, such as parentNode and nextNode. The root must not be null.
        whatToShow - flag specifies which node types may appear in the logical view of the tree presented by the tree-walker. See the description of NodeFilter for the set of possible SHOW_ values.These flags can be combined using OR.
        filter - NodeFilter to be used with this TreeWalker, or null to indicate no filter.
        Returns:
        The newly created TreeWalker.
        Throws:
        DOMException - NOT_SUPPORTED_ERR: Raised if the specified root is null.
      • getPreviousElementSibling

        public Element getPreviousElementSibling()

        Returns the previous sibling element node of this element. null if this element has no element sibling nodes that come before this one in the document tree.

        Specified by:
        getPreviousElementSibling in interface IElementTraversal
      • getNextElementSibling

        public Element getNextElementSibling()

        Returns the next sibling element node of this element. null if this element has no element sibling nodes that come after this one in the document tree.

        Specified by:
        getNextElementSibling in interface IElementTraversal
      • querySelectorAll

        public HTMLCollection querySelectorAll(String selector)

        Returns a NodeList of all the Elements in document, which match selector

        Specified by:
        querySelectorAll in interface IParentNode
        Parameters:
        selector - The query selector
        Returns:
        HTMLCollection
      • querySelector

        public Element querySelector(String selector)

        Returns the first Element in document, which match selector

        Specified by:
        querySelector in interface IParentNode
        Parameters:
        selector - The selector.
        Returns:
        The matched node.
      • importNode

        @DOMNameAttribute(name="importNode")
        public Node importNode(Node importedNode,
                                                                     boolean deep)

        Imports a node from another document to this document, without altering or removing the source node from the original document; this method creates a new copy of the source node.

        Parameters:
        importedNode - The imported node.
        deep - if set to true [deep].
        Returns:
        The Node.
      • getXmlStandalone

        @DOMNameAttribute(name="xmlStandalone")
        public boolean getXmlStandalone()

        An attribute specifying, as part of the XML declaration, whether this document is standalone. This is false when unspecified.

        Value: true if XML standalone; otherwise, false.
      • setXmlStandalone

        @DOMNameAttribute(name="xmlStandalone")
        public void setXmlStandalone(boolean value)

        An attribute specifying, as part of the XML declaration, whether this document is standalone. This is false when unspecified.

        Value: true if XML standalone; otherwise, false.
      • getXmlVersion

        @DOMNameAttribute(name="xmlVersion")
        public String getXmlVersion()

        An attribute specifying, as part of the XML declaration, the version number of this document. If there is no declaration and if this document supports the "XML" feature, the value is "1.0". If this document does not support the "XML" feature, the value is always null.

        Value: The XML version.
      • setXmlVersion

        @DOMNameAttribute(name="xmlVersion")
        public void setXmlVersion(String value)

        An attribute specifying, as part of the XML declaration, the version number of this document. If there is no declaration and if this document supports the "XML" feature, the value is "1.0". If this document does not support the "XML" feature, the value is always null.

        Value: The XML version.
      • getStrictErrorChecking

        @DOMNameAttribute(name="strictErrorChecking")
        public boolean getStrictErrorChecking()

        An attribute specifying whether error checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException on DOM operations or report errors while using Document.normalizeDocument(). In case of error, the behavior is undefined. This attribute is true by default.

        Value: true if strict error checking; otherwise, false.
      • setStrictErrorChecking

        @DOMNameAttribute(name="strictErrorChecking")
        public void setStrictErrorChecking(boolean value)

        An attribute specifying whether error checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException on DOM operations or report errors while using Document.normalizeDocument(). In case of error, the behavior is undefined. This attribute is true by default.

        Value: true if strict error checking; otherwise, false.
      • createEvent

        public Event createEvent(String eventType)

        Creates an Event of a type supported by the implementation.

        Specified by:
        createEvent in interface IDocumentEvent
        Parameters:
        eventType - The eventType parameter specifies the type of Event interface to be created.


        If the Event interface specified is supported by the implementation this method will return a new Event of the interface type requested. If the Event is to be dispatched via the IEventTarget.DispatchEvent method the appropriate Event.InitEvent method must be called after creation in order to initialize the Event's values.

        The IDocumentEvent.CreateEvent method is used in creating Events when it is either inconvenient or unnecessary for the user to create an Event themselves. In cases where the implementation provided Event is insufficient, users may supply their own Event implementations for use with the IEventTarget.DispatchEvent method.

        Returns:
        The newly created Event
        Throws:
        DOMException - NOT_SUPPORTED_ERR: Raised if the implementation does not support the type of Event interface requested
      • write

        @DOMNameAttribute(name="write")
        public void write(String... texts)

        Write a string of text to a document stream opened by open(). Note that the function will produce a document which is not necessarily driven by a DTD and therefore might be produce an invalid result in the context of the document.

        Parameters:
        texts - The string to be parsed into some structure in the document structure model.
      • writeLn

        @DOMNameAttribute(name="writeln")
        public void writeLn(String... texts)

        Write a string of text followed by a newline character to a document stream opened by open(). Note that the function will produce a document which is not necessarily driven by a DTD and therefore might be produce an invalid result in the context of the document

        Parameters:
        texts - The string to be parsed into some structure in the document structure model.
      • cloneNode

        public Node cloneNode(boolean deep)

        Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent (parentNode is null) and no user data.

        Specified by:
        cloneNode in class Node
        Parameters:
        deep - if set to true [deep].
        Returns:
        Returns node
      • createExpression

        public IXPathExpression createExpression(String expression,
                                                 IXPathNSResolver resolver)

        Creates a parsed XPath expression with resolved namespaces. This is useful when an expression will be reused in an application since it makes it possible to compile the expression string into a more efficient internal form and preresolve all namespace prefixes which occur within the expression.

        Specified by:
        createExpression in interface IXPathEvaluator
        Parameters:
        expression - The XPath expression string to be parsed.
        resolver - The resolver permits translation of all prefixes, including the xml namespace prefix, within the XPath expression into appropriate namespace URIs. If this is specified as null, any namespace prefix within the expression will result in DOMException being thrown with the code NAMESPACE_ERR.
        Returns:
        The compiled form of the XPath expression.
        Throws:
        DOMException - INVALID_EXPRESSION_ERR: Raised if the expression is not legal according to the rules of the IXPathEvaluator.
        DOMException - NAMESPACE_ERR: Raised if the expression contains namespace prefixes which cannot be resolved by the specified IXPathNSResolver.
      • createNSResolver

        public IXPathNSResolver createNSResolver(Node nodeResolver)

        Adapts any DOM node to resolve namespaces so that an XPath expression can be easily evaluated relative to the context of the node where it appeared within the document. This adapter works like the DOM Level 3 method lookupNamespaceURI on nodes in resolving the namespaceURI from a given prefix using the current information available in the node's hierarchy at the time lookupNamespaceURI is called, also correctly resolving the implicit xml prefix.

        Specified by:
        createNSResolver in interface IXPathEvaluator
        Parameters:
        nodeResolver - The node to be used as a context for namespace resolution.
        Returns:
        IXPathNSResolver which resolves namespaces with respect to the definitions in scope for a specified node.
      • evaluate

        public IXPathResult evaluate(String expression,
                                     Node contextNode,
                                     IXPathNSResolver resolver,
                                     int type,
                                     Object result)

        Evaluates an XPath expression string and returns a result of the specified type if possible.

        Specified by:
        evaluate in interface IXPathEvaluator
        Parameters:
        expression - The XPath expression string to be parsed and evaluated.
        contextNode - The context is context node for the evaluation of this XPath expression.
        resolver - The resolver permits translation of all prefixes, including the xml namespace prefix, within the XPath expression into appropriate namespace URIs.
        type - If a specific type is specified, then the result will be returned as the corresponding type.
        result - The result specifies a specific result object which may be reused and returned by this method.
        Returns:
        The result of the evaluation of the XPath expression.