pub struct Element(_);
Implementations§
source§impl Element
impl Element
pub fn as_node(&self) -> Node
pub fn append_element(self, document: &mut Document, element: Element)
sourcepub fn append_new_element(
self,
document: &mut Document,
element: impl Into<NewElement>
) -> Element
pub fn append_new_element( self, document: &mut Document, element: impl Into<NewElement> ) -> Element
Examples found in repository?
examples/readme.rs (lines 12-15)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
fn main() {
let mut doc = Document::from_str("<root><potato /></root>").unwrap();
let root = doc.root();
let potato = root
.query_selector(&doc, &Selector::new("potato").unwrap())
.unwrap();
potato.append_new_element(
&mut doc,
("wow", [("easy", "true"), ("x", "200"), ("a-null", "\0")]),
);
let decl = Declaration::v1_1();
doc.set_declaration(Some(decl));
doc.set_doctype(Some("not-html"));
println!("{}", doc.to_string_pretty());
}
pub fn append_new_element_after( self, document: &mut Document, new_element: impl Into<NewElement> ) -> Element
pub fn append_text(self, document: &mut Document, text: &str) -> Text
pub fn append_cdata(self, document: &mut Document, text: &str) -> CDataSection
pub fn append_comment(self, document: &mut Document, text: &str) -> Comment
pub fn set_text(self, document: &mut Document, text: &str)
pub fn remove_child(self, document: &mut Document, node: Node)
pub fn parent(self, document: &Document) -> Option<Element>
pub fn child_nodes(self, document: &Document) -> &[Node]
pub fn children(self, document: &Document) -> Vec<Element>
pub fn name<'d>(&self, document: &'d Document) -> &'d str
pub fn prefix<'d>(&self, document: &'d Document) -> Option<&'d str>
pub fn attributes<'d>( &self, document: &'d Document ) -> &'d IndexMap<QName, String>
pub fn attribute<'d>(&self, document: &'d Document, name: &str) -> Option<&'d str>
pub fn set_attribute(&self, document: &mut Document, name: &str, value: &str)
pub fn remove_attribute(&self, document: &mut Document, name: &str)
pub fn display(&self, document: &Document) -> String
pub fn walk<'d>( &self, doc: &'d Document ) -> Box<dyn Iterator<Item = Element> + 'd>
pub fn next_sibling_element(&self, doc: &Document) -> Option<Element>
pub fn prev_sibling_element(&self, doc: &Document) -> Option<Element>
sourcepub fn query_selector(
&self,
doc: &Document,
selector: &Selector
) -> Option<Element>
pub fn query_selector( &self, doc: &Document, selector: &Selector ) -> Option<Element>
Examples found in repository?
examples/readme.rs (line 10)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
fn main() {
let mut doc = Document::from_str("<root><potato /></root>").unwrap();
let root = doc.root();
let potato = root
.query_selector(&doc, &Selector::new("potato").unwrap())
.unwrap();
potato.append_new_element(
&mut doc,
("wow", [("easy", "true"), ("x", "200"), ("a-null", "\0")]),
);
let decl = Declaration::v1_1();
doc.set_declaration(Some(decl));
doc.set_doctype(Some("not-html"));
println!("{}", doc.to_string_pretty());
}
pub fn query_selector_all( &self, doc: &Document, selector: &Selector ) -> Vec<Element>
Trait Implementations§
source§impl PartialEq<Element> for Element
impl PartialEq<Element> for Element
impl Copy for Element
impl Eq for Element
impl StructuralEq for Element
impl StructuralPartialEq for Element
Auto Trait Implementations§
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnwindSafe for Element
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.