HtmlNode

HtmlNode represents HTML DOM node.

HtmlNode Properties

Id : String
Unique node ID.

Name : String
HTML tag name (lowercased).

Type : String
Node type (can be ‘document’, ‘doctype’, ‘element’, ‘text’, ‘comment’, ‘cdata’ and ‘unknown’).

Value : String
The content of text node, comment node or cdata node.

InputValue : String
The value of input element.

HasChildren : Boolean
Indicates that the node element has child nodes.

Index : Integer
The index of the node relative to its siblings.

Attributes : Dict
Element attributes dictionary (name -> value).

InnerHtml : String
Inner HTML content of the node.

OuterHtml : String
Outer HTML content of the node.

HtmlNode Methods

AddChild(children?) : HtmlNode

Appends child elements.

AddChild Parameters

children? : []

Attr(attr) : String

Returns an attribute value.

Attr Parameters

attr : String

Children() : HtmlQuery

Returns child nodes.

Parent() : HtmlNode

Returns the parent node (if any).

Next() : HtmlNode

Returns the next sibling element.

Prev() : HtmlNode

Returns the previous sibling element.

RemoveAttr(attr) : HtmlNode

Removes an attribute.

RemoveAttr Parameters

attr : String

Select(query) : HtmlQuery

Finds nodes using jQuery-like syntax.

Select Parameters

query : String

Closest(selector) : HtmlQuery

Returns the closest parent element matching the selector.

Closest Parameters

selector : String

Is(selector) : Boolean

Checks if the node matches the selector.

Is Parameters

selector : String

SetAttr(attr, value?) : HtmlNode

Sets an attribute value.

SetAttr Parameters

attr : String

value? : String

SetHtml(html) : HtmlNode

Sets HTML content of the node.

SetHtml Parameters

html : String

SetText(text) : HtmlNode

Sets text content of the node.

SetText Parameters

text : String

Text() : String

Extracts text content from the node.

HtmlQuery

HtmlQuery is an enhanced array of HTML nodes (HtmlNode[]).
HtmlQuery has a number of methods to search, filter or modify HTML content.

HtmlQuery Properties

InnerHtml : String
Inner HTML content of the single element in the selection, or null otherwise.

OuterHtml : String
Outer HTML content of all the nodes in the selection.

HtmlQuery Methods

AddAfter(elements?) : HtmlQuery

Appends elements after each node of the selection.

AddAfter Parameters

elements? : []

AddBefore(elements?) : HtmlQuery

Inserts elements before each node of the selection.

AddBefore Parameters

elements? : []

AddChild(children?) : HtmlQuery

Appends child elements into each element of the selection.

AddChild Parameters

children? : []

Attr(attr) : String

Returns attribute value of the first element in the selection.

Attr Parameters

attr : String

Children() : HtmlQuery

Returns children of each element in the selection.

Parent(selector?) : HtmlQuery

Returns the parent of each node in the selection.

Parent Parameters

selector? : String

Next(selector?) : HtmlQuery

Returns the next sibling of each node in the selection.

Next Parameters

selector? : String

NextAll(selector?) : HtmlQuery

Returns all next siblings of each node in the selection.

NextAll Parameters

selector? : String

Remove(selector?) : HtmlQuery

Removes all selected nodes from the document.

Remove Parameters

selector? : String

RemoveAttr(attr) : HtmlQuery

Removes an attribute from all elements in the selection.

RemoveAttr Parameters

attr : String

Select(query) : HtmlQuery

Finds nodes using jQuery-like syntax.

Select Parameters

query : String

Closest(selector) : HtmlQuery

Returns the closest parent element matching the selector.

Closest Parameters

selector : String

Is(selector) : Boolean

Checks if at least one node in the selection matches the selector.

Is Parameters

selector : String

SetAttr(attr, value?) : HtmlQuery

Sets an attribute for each element in the selection.

SetAttr Parameters

attr : String

value? : String

SetHtml(html) : HtmlQuery

Sets HTML content of each node in the selection.

SetHtml Parameters

html : String

SetText(text) : HtmlQuery

Sets text content of each node in the selection.

SetText Parameters

text : String

Text(formatted = false) : String

Extracts text content from all the nodes in the selection.

Text Parameters

formatted? : Boolean

XmlNode

XmlNode represents XML DOM node.

XmlNode Properties

Name : String
XML tag name.

Type : String
Node type (can be ‘document’, ‘doctype’, ‘element’, ‘text’, ‘comment’, ‘cdata’ and ‘unknown’).

Value : String
The content of text node, comment node or cdata node.

HasChildren : Boolean
Indicates that the node element has child nodes.

Index : Integer
The index of the node relative to its siblings.

Attributes : Dict
Element attributes dictionary (name -> value).

InnerXml : String
Inner XML content of the node.

OuterXml : String
Outer XML content of the node.

XmlNode Methods

Attr(attr) : String

Returns an attribute value.

Attr Parameters

attr : String

Children() : XmlNode[]

Returns child nodes.

Parent() : XmlNode

Returns the parent node.

Select(xpath) : XmlNode[]

Finds nodes using XPath.

Select Parameters

xpath : String

Text() : String

Extracts text content from the node.

ToObject()

Converts node to dictionary.

Leave a Comment

Your email address will not be published. Required fields are marked *