pub struct Document {
pub errors: Vec<Cow<'static, str>>,
pub quirks_mode: QuirksMode,
/* private fields */
}
Expand description
Document represents an HTML document to be manipulated.
Fields§
§errors: Vec<Cow<'static, str>>
Errors that occurred during parsing.
quirks_mode: QuirksMode
The document’s quirks mode.
Implementations§
source§impl Document
impl Document
sourcepub fn html(&self) -> StrTendril
pub fn html(&self) -> StrTendril
Gets the HTML contents of the document. It includes the text and comment nodes.
sourcepub fn text(&self) -> StrTendril
pub fn text(&self) -> StrTendril
Gets the text content of the document.
source§impl Document
impl Document
sourcepub fn select(&self, sel: &str) -> Selection<'_>
pub fn select(&self, sel: &str) -> Selection<'_>
Gets the descendants of the root document node in the current, filter by a selector. It returns a new selection object containing these matched elements.
§Panics
Panics if failed to parse the given CSS selector.
sourcepub fn nip(&self, sel: &str) -> Selection<'_>
pub fn nip(&self, sel: &str) -> Selection<'_>
Alias for select
, it gets the descendants of the root document node in the current, filter by a selector.
It returns a new selection object containing these matched elements.
§Panics
Panics if failed to parse the given CSS selector.
sourcepub fn try_select(&self, sel: &str) -> Option<Selection<'_>>
pub fn try_select(&self, sel: &str) -> Option<Selection<'_>>
Gets the descendants of the root document node in the current, filter by a selector. It returns a new selection object containing these matched elements.
sourcepub fn select_matcher<'a>(&'a self, matcher: &'a Matcher) -> Selection<'a>
pub fn select_matcher<'a>(&'a self, matcher: &'a Matcher) -> Selection<'a>
Gets the descendants of the root document node in the current, filter by a matcher. It returns a new selection object containing these matched elements.
Trait Implementations§
source§impl From<Tendril<UTF8>> for Document
impl From<Tendril<UTF8>> for Document
source§fn from(html: StrTendril) -> Document
fn from(html: StrTendril) -> Document
source§impl TreeSink for Document
impl TreeSink for Document
§type Handle = NodeId
type Handle = NodeId
Handle
is a reference to a DOM node. The tree builder requires
that a Handle
implements Clone
to get another reference to
the same node.source§fn parse_error(&mut self, msg: Cow<'static, str>)
fn parse_error(&mut self, msg: Cow<'static, str>)
source§fn get_document(&mut self) -> NodeId
fn get_document(&mut self) -> NodeId
Document
node.source§fn get_template_contents(&mut self, target: &NodeId) -> NodeId
fn get_template_contents(&mut self, target: &NodeId) -> NodeId
source§fn set_quirks_mode(&mut self, mode: QuirksMode)
fn set_quirks_mode(&mut self, mode: QuirksMode)
source§fn elem_name(&self, target: &NodeId) -> ExpandedName<'_>
fn elem_name(&self, target: &NodeId) -> ExpandedName<'_>
source§fn create_element(
&mut self,
name: QualName,
attrs: Vec<Attribute>,
flags: ElementFlags
) -> NodeId
fn create_element( &mut self, name: QualName, attrs: Vec<Attribute>, flags: ElementFlags ) -> NodeId
source§fn create_comment(&mut self, text: StrTendril) -> NodeId
fn create_comment(&mut self, text: StrTendril) -> NodeId
source§fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> NodeId
fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> NodeId
source§fn append(&mut self, parent: &NodeId, child: NodeOrText<NodeId>)
fn append(&mut self, parent: &NodeId, child: NodeOrText<NodeId>)
source§fn append_before_sibling(&mut self, sibling: &NodeId, child: NodeOrText<NodeId>)
fn append_before_sibling(&mut self, sibling: &NodeId, child: NodeOrText<NodeId>)
source§fn append_based_on_parent_node(
&mut self,
element: &NodeId,
prev_element: &NodeId,
child: NodeOrText<NodeId>
)
fn append_based_on_parent_node( &mut self, element: &NodeId, prev_element: &NodeId, child: NodeOrText<NodeId> )
source§fn append_doctype_to_document(
&mut self,
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril
)
fn append_doctype_to_document( &mut self, name: StrTendril, public_id: StrTendril, system_id: StrTendril )
DOCTYPE
element to the Document
node.source§fn add_attrs_if_missing(&mut self, target: &NodeId, attrs: Vec<Attribute>)
fn add_attrs_if_missing(&mut self, target: &NodeId, attrs: Vec<Attribute>)
source§fn remove_from_parent(&mut self, target: &NodeId)
fn remove_from_parent(&mut self, target: &NodeId)
source§fn reparent_children(&mut self, node: &NodeId, new_parent: &NodeId)
fn reparent_children(&mut self, node: &NodeId, new_parent: &NodeId)
source§fn mark_script_already_started(&mut self, _node: &Self::Handle)
fn mark_script_already_started(&mut self, _node: &Self::Handle)
<script>
as “already started”.source§fn pop(&mut self, _node: &Self::Handle)
fn pop(&mut self, _node: &Self::Handle)
source§fn associate_with_form(
&mut self,
_target: &Self::Handle,
_form: &Self::Handle,
_nodes: (&Self::Handle, Option<&Self::Handle>)
)
fn associate_with_form( &mut self, _target: &Self::Handle, _form: &Self::Handle, _nodes: (&Self::Handle, Option<&Self::Handle>) )
source§fn is_mathml_annotation_xml_integration_point(
&self,
_handle: &Self::Handle
) -> bool
fn is_mathml_annotation_xml_integration_point( &self, _handle: &Self::Handle ) -> bool
source§fn set_current_line(&mut self, _line_number: u64)
fn set_current_line(&mut self, _line_number: u64)
source§fn complete_script(&mut self, _node: &Self::Handle) -> NextParserState
fn complete_script(&mut self, _node: &Self::Handle) -> NextParserState
script
element is complete.