Struct xmlem::Element

source ·
pub struct Element(_);

Implementations§

source§

impl Element

source

pub fn as_node(&self) -> Node

source

pub fn append_element(self, document: &mut Document, element: Element)

source

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());
}
source

pub fn append_new_element_after( self, document: &mut Document, new_element: impl Into<NewElement> ) -> Element

source

pub fn append_text(self, document: &mut Document, text: &str) -> Text

source

pub fn append_cdata(self, document: &mut Document, text: &str) -> CDataSection

source

pub fn append_comment(self, document: &mut Document, text: &str) -> Comment

source

pub fn set_text(self, document: &mut Document, text: &str)

source

pub fn remove_child(self, document: &mut Document, node: Node)

source

pub fn parent(self, document: &Document) -> Option<Element>

source

pub fn child_nodes(self, document: &Document) -> &[Node]

source

pub fn children(self, document: &Document) -> Vec<Element>

source

pub fn name<'d>(&self, document: &'d Document) -> &'d str

source

pub fn prefix<'d>(&self, document: &'d Document) -> Option<&'d str>

source

pub fn attributes<'d>( &self, document: &'d Document ) -> &'d IndexMap<QName, String>

source

pub fn attribute<'d>(&self, document: &'d Document, name: &str) -> Option<&'d str>

source

pub fn set_attribute(&self, document: &mut Document, name: &str, value: &str)

source

pub fn remove_attribute(&self, document: &mut Document, name: &str)

source

pub fn display(&self, document: &Document) -> String

source

pub fn walk<'d>( &self, doc: &'d Document ) -> Box<dyn Iterator<Item = Element> + 'd>

source

pub fn next_sibling_element(&self, doc: &Document) -> Option<Element>

source

pub fn prev_sibling_element(&self, doc: &Document) -> Option<Element>

source

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());
}
source

pub fn query_selector_all( &self, doc: &Document, selector: &Selector ) -> Vec<Element>

Trait Implementations§

source§

impl Clone for Element

source§

fn clone(&self) -> Element

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Element

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Element> for Node

source§

fn from(n: Element) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Element> for Element

source§

fn eq(&self, other: &Element) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Element

source§

impl Eq for Element

source§

impl StructuralEq for Element

source§

impl StructuralPartialEq for Element

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more