pub struct Text { /* private fields */ }
Expand description
XML text value.
Example: Bar
in <foo>Bar</foo>
, or hello
and world
in <greeting>hello<sep/>world</greeting>
.
Implementations§
Source§impl Text
impl Text
Sourcepub fn get(&self) -> &str
pub fn get(&self) -> &str
Get the text value.
See Xot::text_str
and Xot::text_content_str
for
more convenient ways to get text values.
Sourcepub fn set<S: Into<String>>(&mut self, text: S)
pub fn set<S: Into<String>>(&mut self, text: S)
Set the text value.
use xot::Xot;
let mut xot = Xot::new();
let root = xot.parse(r#"<doc>Example</doc>"#)?;
let doc_el = xot.document_element(root).unwrap();
let text_node = xot.first_child(doc_el).unwrap();
let text = xot.text_mut(text_node).unwrap();
text.set("New text");
assert_eq!(xot.to_string(root).unwrap(), r#"<doc>New text</doc>"#);
Trait Implementations§
impl Eq for Text
impl StructuralPartialEq for Text
Auto Trait Implementations§
impl Freeze for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnwindSafe for Text
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more