[][src]Struct xdoc::Element

pub struct Element {
    pub namespace: Option<String>,
    pub name: String,
    pub attributes: OrdMap,
    pub nodes: Vec<Node>,
}

Represents an Element in an XML Document.

Fields

namespace: Option<String>

The namespace of this element. e.g. in foo:bar, foo is the namespace.

name: String

The name of this element. e.g. in foo:bar, bar is the name.

attributes: OrdMap

Attributes of this element.

nodes: Vec<Node>

Children of this element.

Implementations

impl Element[src]

pub fn from_name<S: AsRef<str>>(name: S) -> Self[src]

Create a new element using the given name.

pub fn children(&self) -> impl Iterator<Item = &Element>[src]

Returns the 'child' elements of the current element. Consider the XML document:

<r>
  <a/>
  <b/>
</r>

r's children() function would return an iterator over 'a' and 'b'. Text nodes, processing instructions and comments are skipped/ignored by the iterator.

pub fn add_child(&mut self, element: Element)[src]

Add an element as a child of this element.

pub fn fullname(&self) -> String[src]

The fullname of the element (including both the namespace and the name).

pub fn has_children(&self) -> bool[src]

Does this element have any sub elements. For example, if the element is empty or contains only text and/or pis and/or comments, then false. if the element has elements, then true.

pub fn is_text(&self) -> bool[src]

Returns true if there is exactly one sub node, and that sub node is either text or cdata.

pub fn write<W>(
    &self,
    writer: &mut W,
    opts: &WriteOpts,
    depth: usize
) -> Result<()> where
    W: Write
[src]

Write the element to the Write object.

Trait Implementations

impl Clone for Element[src]

impl Debug for Element[src]

impl Default for Element[src]

impl Eq for Element[src]

impl<'a> From<&'a Element> for Cow<'a, Element>[src]

impl<'a> From<Element> for Cow<'a, Element>[src]

impl Hash for Element[src]

impl PartialEq<Element> for Element[src]

impl PartialOrd<Element> for Element[src]

impl StructuralEq for Element[src]

impl StructuralPartialEq for Element[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.