Meeseeks v0.11.0 Meeseeks.Result View Source
Results are the product of running selections on a document, and package
together a node id and the Meeseeks.Document
for which that id is
valid.
Results are generally used in one of two ways: either data, such as an element's tag, is extracted from a result, or further selections are ran using the result as a source.
When a result is used as a source for further selection, the original document the result came from is used for context, meaning that questions about the results ancestors may be asked, but also that queries involving ancestors need to account for the whole document, not just the contents of the result.
Examples
iex> import Meeseeks.CSS
iex> document = Meeseeks.parse("<div><ul><li>1</li><li>2</li></ul></div>")
#Meeseeks.Document<{...}>
iex> ul = Meeseeks.one(document, css("ul"))
#Meeseeks.Result<{ <ul><li>1</li><li>2</li></ul> }>
iex> Meeseeks.tag(ul)
"ul"
iex> Meeseeks.all(ul, css("li")) |> List.last()
#Meeseeks.Result<{ <li>2</li> }>
Link to this section Summary
Functions
Returns the value for attribute in result, or nil if there isn't one
Returns the result's attributes list, which may be empty, or nil if result represents a node without attributes
Returns the combined data of result or result's children, which may be an empty string
Returns a map of result's data attributes, or nil if result represents a node without attributes
Returns the combined HTML of result and its descendants
Returns the combined text of result or result's children, which may be an empty string
Returns result's tag, or nil if result represents a node without a tag
Returns the combined text of result or result's descendants, which may be an empty string
Returns a Meeseeks.TupleTree
of result and its descendants
Link to this section Types
t()
View Source
t() :: %Meeseeks.Result{
document: Meeseeks.Document.t(),
id: Meeseeks.Document.node_id()
}
t() :: %Meeseeks.Result{ document: Meeseeks.Document.t(), id: Meeseeks.Document.node_id() }
Link to this section Functions
attr(result, attribute)
View Source
attr(Meeseeks.Result.t(), String.t()) :: String.t() | nil
attr(Meeseeks.Result.t(), String.t()) :: String.t() | nil
Returns the value for attribute in result, or nil if there isn't one.
attrs(result)
View Source
attrs(Meeseeks.Result.t()) :: [{String.t(), String.t()}] | nil
attrs(Meeseeks.Result.t()) :: [{String.t(), String.t()}] | nil
Returns the result's attributes list, which may be empty, or nil if result represents a node without attributes.
data(result)
View Source
data(Meeseeks.Result.t()) :: String.t()
data(Meeseeks.Result.t()) :: String.t()
Returns the combined data of result or result's children, which may be an empty string.
Data is the content of <script>
or <style>
tags, or the content of
comments starting with "[CDATA[" and ending with "]]". The latter behavior
is to support the extraction of CDATA from HTML, since HTML5 parsers parse
CDATA as comments.
dataset(result)
View Source
dataset(Meeseeks.Result.t()) :: %{optional(String.t()) => String.t()} | nil
dataset(Meeseeks.Result.t()) :: %{optional(String.t()) => String.t()} | nil
Returns a map of result's data attributes, or nil if result represents a node without attributes.
Behaves like HTMLElement.dataset; only valid data attributes are included, and attribute names have "data-" removed and are converted to camelCase.
See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
html(result)
View Source
html(Meeseeks.Result.t()) :: String.t()
html(Meeseeks.Result.t()) :: String.t()
Returns the combined HTML of result and its descendants.
own_text(result)
View Source
own_text(Meeseeks.Result.t()) :: String.t()
own_text(Meeseeks.Result.t()) :: String.t()
Returns the combined text of result or result's children, which may be an empty string.
tag(result)
View Source
tag(Meeseeks.Result.t()) :: String.t() | nil
tag(Meeseeks.Result.t()) :: String.t() | nil
Returns result's tag, or nil if result represents a node without a tag.
text(result)
View Source
text(Meeseeks.Result.t()) :: String.t()
text(Meeseeks.Result.t()) :: String.t()
Returns the combined text of result or result's descendants, which may be an empty string.
tree(result)
View Source
tree(Meeseeks.Result.t()) :: Meeseeks.TupleTree.node_t()
tree(Meeseeks.Result.t()) :: Meeseeks.TupleTree.node_t()
Returns a Meeseeks.TupleTree
of result and its descendants.