moon_html.html
One attribute; duplicate names keep the first occurrence.
name: string | Attribute name, lowercased. |
|---|---|
value: string | Attribute value with entities decoded. |
tag: string | Lowercase tag name, or |
|---|---|
text: string | Text content, for a text node. |
attrs: [HtmlAttr] | Attributes in source order; a duplicate name keeps the first. |
parent: int | Arena index of the enclosing element. |
first_child: int | Arena index of the first child, or -1. |
last_child: int | Arena index of the last child, or -1. |
next_sibling: int | Arena index of the next sibling, or -1. |
A parsed document: node 0 is the synthetic root.
nodes: [ElemData] | The arena backing the document; index 0 is the synthetic root. |
|---|
A handle to one element in a document's arena.
nodes: [ElemData] | The document's arena, shared with every other handle into it. |
|---|---|
index: int | Arena index of the element this handle names. |
Decodes the common named and numeric entities; unknown entities pass through literally.
text: Raw markup text to decode.
Parses source tolerantly; never errors.
source: HTML text to parse; malformed markup is recovered rather than rejected.
use moon_html.html
fn main() {
let doc = html.parse("<main><a class='item' href='/moon'>moon</a></main>")
let link = doc.select("main > a.item")[0]
println(link.text()) // moon
println(link.attr("href").unwrap()) // /moon
}Matching descendants of this node, in document order.
sel: CSS selector matched against this node’s descendants.
The attribute's decoded value, or none.
name: Attribute name, matched lowercased.
The element's lowercase tag name ("" for text nodes).
Concatenated descendant text.
Inner HTML (reserialized from the tree; script/style content and text are emitted as parsed).
moon_html.selector
One simple predicate inside a compound.
kind: string | What the predicate tests: an id, a class, or an attribute. |
|---|---|
name: string | Identifier, class name, or attribute name the predicate names. |
value: string | Value the attribute must have, where the predicate carries one. |
A compound plus the combinator that links it to the compound on its right ("" for the rightmost, " " descendant, ">" child).
tag: string | Tag name the compound requires, or |
|---|---|
simples: [Simple] | The id, class, and attribute predicates that must all hold. |
combinator: string | How this compound links to the one on its right: |
All descendants of root matching selector sel, in document order.
nodes: The document's node arena.root: Arena index the results must descend from.sel: CSS selector, comma groups included.