pub enum Node {
Comment(Comment),
Doctype(Doctype),
Fragment(Fragment),
Element(Element),
Text(Text),
UnsafeText(UnsafeText),
}
Expand description
An HTML node.
Variants§
Comment(Comment)
A comment.
<!-- I'm a comment! -->
Doctype(Doctype)
A doctype.
<!DOCTYPE html>
Fragment(Fragment)
A fragment.
<>
I'm in a fragment!
</>
Element(Element)
An element.
<div class="container">
I'm in an element!
</div>
Text(Text)
A text node.
<div>
I'm a text node!
</div>
UnsafeText(UnsafeText)
An unsafe text node.
Warning
Node::UnsafeText
is not escaped when rendered, and as such, can
allow for XSS attacks. Use with caution!
Implementations§
source§impl Node
impl Node
sourcepub const EMPTY: Node = Self::Fragment(Fragment::EMPTY)
pub const EMPTY: Node = Self::Fragment(Fragment::EMPTY)
A Node::Fragment
with no children.
sourcepub fn from_typed<E>(element: E, children: Option<Vec<Node, Global>>) -> Nodewhere
E: TypedElement,
Available on crate feature typed
only.
pub fn from_typed<E>(element: E, children: Option<Vec<Node, Global>>) -> Nodewhere E: TypedElement,
typed
only.Create a new Node
from a TypedElement
.
sourcepub fn pretty(self) -> Pretty
Available on crate feature pretty
only.
pub fn pretty(self) -> Pretty
pretty
only.Wrap the node in a pretty-printing wrapper.
sourcepub fn as_children(&self) -> Option<&[Node]>
pub fn as_children(&self) -> Option<&[Node]>
Borrow the children of the node, if it is an element (with children) or a fragment.
sourcepub fn children_iter(&self) -> impl Iterator<Item = &Node>
pub fn children_iter(&self) -> impl Iterator<Item = &Node>
Iterate over the children of the node.
sourcepub fn children(self) -> Option<Vec<Node, Global>>
pub fn children(self) -> Option<Vec<Node, Global>>
The children of the node, if it is an element (with children) or a fragment.
sourcepub fn into_children(self) -> impl Iterator<Item = Node>
pub fn into_children(self) -> impl Iterator<Item = Node>
Iterate over the children of the node, consuming it.
sourcepub const fn as_comment(&self) -> Option<&Comment>
pub const fn as_comment(&self) -> Option<&Comment>
Try to get this node as a Comment
, if it is one.
sourcepub const fn as_doctype(&self) -> Option<&Doctype>
pub const fn as_doctype(&self) -> Option<&Doctype>
Try to get this node as a Doctype
, if it is one.
sourcepub const fn as_fragment(&self) -> Option<&Fragment>
pub const fn as_fragment(&self) -> Option<&Fragment>
Try to get this node as a Fragment
, if it is one.
sourcepub const fn as_element(&self) -> Option<&Element>
pub const fn as_element(&self) -> Option<&Element>
Try to get this node as an Element
, if it is one.
sourcepub const fn as_unsafe_text(&self) -> Option<&UnsafeText>
pub const fn as_unsafe_text(&self) -> Option<&UnsafeText>
Try to get this node as an UnsafeText
, if it is one.