Struct svgdom::Document [] [src]

pub struct Document {
    // some fields omitted
}

Container of Nodes.

Methods

impl Document
[src]

Constructs a new Document.

Constructs a new Document from data using default ParseOptions.

Constructs a new Document from data using supplied ParseOptions.

Constructs a new Node with Element type.

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

Constructs a new Node using 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.

Constructs a new element with text node.

Examples

use svgdom::{Document, ElementId};

let doc = Document::new();
doc.append(&doc.create_element_with_text(ElementId::Text, "text"));

assert_eq!(doc.to_string(),
"<text>
    text
</text>
");

Returns root Node.

Returns first child of the root Node.

Panics

Panics if the root node is currently mutability borrowed.

Returns first child with NodeType::Element of the root Node.

Panics

Panics if the root node is currently mutability borrowed.

Examples

use svgdom::Document;

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

assert_eq!(doc.first_child().unwrap().is_element(), false);
assert_eq!(doc.first_element_child().unwrap().is_element(), true);

Returns 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_id(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 iterator over descendant SVG elements.

Returns iterator over descendant SVG nodes.

Trait Implementations

impl WriteBuffer for Document
[src]

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

Writes data to 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 String using specified WriteOptions.