[][src]Struct htmldom_read::Node

pub struct Node { /* fields omitted */ }

Contains information about opening and corresponding closing tags. It also can contain the value of the text between opening and closing tags if there are no children. Otherwise, if there are children mixed with text then each text chunk is separated in it's own node with other children in order they appear in the code.

Methods

impl Node[src]

pub fn new() -> Self[src]

Create new empty node with no children nor tags.

pub fn from_html(
    html: &str,
    settings: &LoadSettings
) -> Result<Option<Node>, Error>
[src]

Load node tree from HTML string.

The root node has no start, end or text elements. It does have only children in it. When passing empty code, None will be returned. If there is an error parsing the HTML, then this function will fail and return the error type that occurred.

pub fn from_html_first(html: &str, settings: &LoadSettings) -> Option<Self>[src]

Load the first node from HTML string without wrapping node to the tree with root (empty first node). Just return the exact single node.

Failures

None is returned if string does not contain any node (is empty).

pub fn start(&self) -> &Option<OpeningTag>[src]

Start tag information.

pub fn end(&self) -> Option<&str>[src]

End tag information.

pub fn text(&self) -> Option<&str>[src]

Text that appears between opening and closing tags.

pub fn children(&self) -> &Children[src]

Children tags of this node.

pub fn tag_name(&self) -> Option<&str>[src]

The name of the tag that is represented by the node.

pub fn attributes(&self) -> Option<&Vec<Attribute>>[src]

Start tag attributes.

pub fn attribute_by_name(&self, key: &str) -> Option<&Attribute>[src]

Find attribute by it's name.

pub fn put_attribute(&mut self, attr: Attribute) -> Result<(), Attribute>[src]

Try saving given attribute in this node.

Failure

If this attribute is already present then this function will not change it. If you need to overwrite the attribute anyway use [overwrite_attribute].

pub fn overwrite_attribute(&mut self, attr: Attribute)[src]

Save this attribute in the node. If it is already present then overwrite it.

pub fn children_fetch(&self) -> ChildrenFetch[src]

Get children fetcher for this node to find children that apply to some criteria.

pub fn children_fetch_mut(&mut self) -> ChildrenFetchMut[src]

pub fn to_string(&self) -> String[src]

Convert this node and all it's children into HTML string.

pub fn change_name(&mut self, name: &str)[src]

Change name of opening and closing tags (if any).

pub fn change_opening_name(&mut self, name: &str)[src]

Change the name of only opening tag if it exists.

pub fn change_closing_name(&mut self, name: &str)[src]

Change the name of only closing tag if it exists.

pub fn children_mut(&mut self) -> &mut Children[src]

Mutable access to array of node's children.

pub fn clone_without_children(&self) -> Self[src]

Clone this node without cloning children leaving new node with empty children list.

pub fn wrap_to_root(self) -> Result<Self, Self>[src]

Try wrapping this node into root. This makes it possible to use this node as individual tree.

It is required for trees to start with empty node only with children. Many functions rely on this rule. For example, Fetch functions filter data only in children ignoring parent attributes and data.

Failures

If this node already is root it is returned back in Err.

pub fn is_root(&self) -> bool[src]

Check whether this node is the root of the tree.

Trait Implementations

impl Clone for Node[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq<Node> for Node[src]

impl From<Node> for NodeAccess[src]

impl Default for Node[src]

impl Debug for Node[src]

Auto Trait Implementations

impl Send for Node

impl Sync for Node

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]