Struct svgdom::Document [] [src]

pub struct Document {
    pub root: Node,
}

Container of Nodes.

Fields

Root node.

Methods

impl Document
[src]

Constructs a new Document.

Constructs a new Document from the data using a default ParseOptions.

Constructs a new Document from the data using a supplied ParseOptions.

Constructs a new Node with Element type.

Constructed node do belong to this document, but not added to it tree structure.

Panics

Panics if a string tag name is empty.

Constructs a new Node using the supplied NodeType.

Constructed node do belong to this document, but not added to it tree structure.

This method should be used for any non-element nodes.

Returns the root Node.

Returns the first child of the root Node.

Panics

Panics if the root node is currently mutability borrowed.

Returns the first child with svg tag name of the root Node.

In most of the cases result of this method and first_element_child() will be the same, but an additional check may be helpful.

Panics

Panics if the root node is currently mutability borrowed.

Examples

use svgdom::{Document, ElementId};

let doc = Document::from_data(b"<!--comment--><svg/>").unwrap();

assert_eq!(doc.svg_element().unwrap().is_tag_name(ElementId::Svg), true);

Appends a new child to root node, after existing children, and returns it.

Panics

Panics if the node, the new child, or one of their adjoining nodes is currently borrowed.

Examples

use svgdom::{Document, ElementId};

let doc = Document::new();
doc.append(&doc.create_element(ElementId::Svg));

assert_eq!(doc.to_string(), "<svg/>\n");

Returns an iterator over descendants.

Returns an iterator to this node's children elements.

Panics

Panics if the node is currently mutability borrowed.

Removes only the children nodes specified by the predicate.

The root node ignored.

Trait Implementations

impl Default for Document
[src]

Returns the "default value" for a type. Read more

impl WriteBuffer for Document
[src]

Writes data to the Vec<u8> buffer using specified WriteOptions.

Writes data to the Vec<u8> buffer using default WriteOptions.

impl Display for Document
[src]

Formats the value using the given formatter.

impl WriteToString for Document
[src]

Writes data to the String using specified WriteOptions.