A handle on a node inside a Sablon.XML.Document.
The API mirrors the subset of Nokogiri used by the Ruby sablon gem:
navigation (parent/1, ancestors/2, next_element/1), querying
(xpath/2, css/2) and in-place mutation (remove/1,
add_next_sibling/2, replace/2, ...). All mutating functions operate on
the document's process dictionary store and therefore affect every handle pointing at the
same node.
Summary
Functions
Appends child to the node's children, detaching it from a previous parent.
Inserts sibling directly after node.
Inserts sibling directly before node.
Ancestors of the node, closest first.
Like css/2 but returns only the first match.
Like xpath/3 but returns only the first match.
Returns true when the node is still attached to its document.
Fetches a single attribute value or nil.
All attributes as an ordered keyword-like list of {name, value} tuples.
All child nodes, in document order.
Alias of text/1, mirroring Nokogiri's content.
Evaluates a (very small subset of a) CSS selector, e.g. Relationship[Id="rId4"].
Removes an attribute.
Deep copies the node. The copy is detached and, by default, belongs to the
same document. Pass a target document to copy across documents.
Only the child nodes that are elements.
The first child element or nil.
Serialises the children of node, i.e. its inner XML.
The local part of the node name, i.e. "p" for "w:p".
The qualified node name, e.g. "w:p".
Builds a new, detached element node belonging to doc.
Builds a new, detached text node.
The next sibling that is an element, mirroring Nokogiri's next_element.
The next sibling node, of any type.
Alias of name/1, mirroring Nokogiri's node_name.
Serialises a list of nodes to XML.
The parent node, or nil for the document node and detached nodes.
The namespace prefix of the node name or nil.
Prepends child to the node's children.
The previous sibling that is an element.
The previous sibling node, of any type.
Sets an attribute, preserving the position of an existing one.
Sets an attribute matched by its local name, keeping whatever prefix it already uses. Does nothing when no such attribute exists.
Detaches the node from its parent. The node itself stays usable.
Replaces node with the given node or list of nodes.
Returns true when both handles point at the same node of the same document.
Alias of xpath/3, mirroring Nokogiri's search.
Replaces all children of node with nodes.
Replaces all children of node with a single text node.
The concatenated text content of the subtree.
Serialises the node (and its subtree) to XML.
Walks the subtree rooted at node in document order, node included.
The node type: :element, :text, :cdata, :comment, :pi, :decl, :doctype or :document.
Evaluates an XPath expression relative to node. See Sablon.XML.XPath.
Types
@type t() :: %Sablon.XML.Node{doc: Sablon.XML.Document.t(), id: non_neg_integer()}
Functions
Appends child to the node's children, detaching it from a previous parent.
Inserts sibling directly after node.
Inserts sibling directly before node.
Ancestors of the node, closest first.
When a selector is given only ancestors matching it are returned. The
selector accepts the same limited form used throughout sablon, e.g.
".//w:p" which matches ancestor elements named w:p.
Like css/2 but returns only the first match.
Like xpath/3 but returns only the first match.
Returns true when the node is still attached to its document.
Fetches a single attribute value or nil.
All attributes as an ordered keyword-like list of {name, value} tuples.
All child nodes, in document order.
Alias of text/1, mirroring Nokogiri's content.
Evaluates a (very small subset of a) CSS selector, e.g. Relationship[Id="rId4"].
Removes an attribute.
@spec dup(t(), Sablon.XML.Document.t() | nil) :: t()
Deep copies the node. The copy is detached and, by default, belongs to the
same document. Pass a target document to copy across documents.
Only the child nodes that are elements.
The first child element or nil.
Serialises the children of node, i.e. its inner XML.
The local part of the node name, i.e. "p" for "w:p".
The qualified node name, e.g. "w:p".
@spec new(binary(), Sablon.XML.Document.t() | t()) :: t()
Builds a new, detached element node belonging to doc.
Mirrors Nokogiri::XML::Node.new(name, document).
@spec new_text(binary(), Sablon.XML.Document.t() | t()) :: t()
Builds a new, detached text node.
The next sibling that is an element, mirroring Nokogiri's next_element.
The next sibling node, of any type.
Alias of name/1, mirroring Nokogiri's node_name.
Serialises a list of nodes to XML.
The parent node, or nil for the document node and detached nodes.
The namespace prefix of the node name or nil.
Prepends child to the node's children.
The previous sibling that is an element.
The previous sibling node, of any type.
Sets an attribute, preserving the position of an existing one.
Sets an attribute matched by its local name, keeping whatever prefix it already uses. Does nothing when no such attribute exists.
Detaches the node from its parent. The node itself stays usable.
Replaces node with the given node or list of nodes.
Returns true when both handles point at the same node of the same document.
Alias of xpath/3, mirroring Nokogiri's search.
Replaces all children of node with nodes.
Replaces all children of node with a single text node.
The concatenated text content of the subtree.
Serialises the node (and its subtree) to XML.
Walks the subtree rooted at node in document order, node included.
The node type: :element, :text, :cdata, :comment, :pi, :decl, :doctype or :document.
Evaluates an XPath expression relative to node. See Sablon.XML.XPath.