pub struct Element {
pub name: String,
pub namespace: Option<String>,
pub namespaces: Vec<Namespace>,
pub attributes: Vec<Attribute>,
pub children: Vec<Node>,
}Expand description
An XML element.
Fields§
§name: StringThe local name, e.g. activity.
namespace: Option<String>The namespace URI of the element name, rarely used in Android XML.
namespaces: Vec<Namespace>Namespaces declared on this element.
attributes: Vec<Attribute>§children: Vec<Node>Implementations§
Source§impl Element
impl Element
pub fn new(name: impl Into<String>) -> Self
Sourcepub fn with_android_namespace(self) -> Self
pub fn with_android_namespace(self) -> Self
Declares xmlns:android on this element.
Sourcepub fn with_attr(
self,
name: impl Into<AttrName>,
value: impl Into<Value>,
) -> Self
pub fn with_attr( self, name: impl Into<AttrName>, value: impl Into<Value>, ) -> Self
Sets an attribute, replacing any previous value.
Sourcepub fn with_opt_attr<V: Into<Value>>(
self,
name: impl Into<AttrName>,
value: Option<V>,
) -> Self
pub fn with_opt_attr<V: Into<Value>>( self, name: impl Into<AttrName>, value: Option<V>, ) -> Self
Sets an attribute when value is Some.
pub fn with_child(self, child: Element) -> Self
pub fn with_children(self, children: impl IntoIterator<Item = Element>) -> Self
Sourcepub fn set_attr(
&mut self,
name: impl Into<AttrName>,
value: impl Into<Value>,
) -> &mut Self
pub fn set_attr( &mut self, name: impl Into<AttrName>, value: impl Into<Value>, ) -> &mut Self
Sets an attribute, replacing the value of any attribute with the same resource ID or, without one, the same name.
Attributes are kept in the order binary XML stores them: framework attributes by resource ID, then the rest by namespace and name.
pub fn push_child(&mut self, child: Element) -> &mut Self
Sourcepub fn attr(&self, namespace: Option<&str>, name: &str) -> Option<&Value>
pub fn attr(&self, namespace: Option<&str>, name: &str) -> Option<&Value>
The value of the attribute name in namespace.
Sourcepub fn android_attr(&self, def: &AttrDef) -> Option<&Value>
pub fn android_attr(&self, def: &AttrDef) -> Option<&Value>
The value of the framework attribute def.
Sourcepub fn elements_named<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = &'a Element> + 'a
pub fn elements_named<'a>( &'a self, name: &'a str, ) -> impl Iterator<Item = &'a Element> + 'a
Child elements named name.
Sourcepub fn elements_mut(&mut self) -> impl Iterator<Item = &mut Element>
pub fn elements_mut(&mut self) -> impl Iterator<Item = &mut Element>
Mutable child elements.
Sourcepub fn element_mut(&mut self, name: &str) -> Option<&mut Element>
pub fn element_mut(&mut self, name: &str) -> Option<&mut Element>
The first child element named name, for editing.
Trait Implementations§
impl StructuralPartialEq for Element
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnsafeUnpin for Element
impl UnwindSafe for Element
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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