PerfectPan/svgo/xml does not have a README file

    ParseError

    pub suberror ParseError {
    ParseError(String, Int)
    } derive(
    Debug
    )

    Malformed input; carries a message and the code unit offset where parsing stopped.
    impl Show for ParseError

    ParseError::output

    fn ParseError::output(self : ParseError, logger : &Logger) -> Unit

    ParseError::to_string

    fn ParseError::to_string(self : ParseError) -> String

    Document

    pub(all) struct Document {
    children : Array[Node]
    } derive(
    Debug
    )

    A parsed XML/SVG document: a sequence of top level nodes, usually a prolog (<?xml ...?>, doctype, comments) followed by one root element.

    Document::each_element

    fn Document::each_element(self : Document, f : (Element, Element?) -> Unit) -> Unit

    Depth first traversal over all elements, parents before children.

    Document::each_element_post

    fn Document::each_element_post(self : Document, f : (Element, Element?) -> Unit) -> Unit

    Depth first traversal, children before parents; useful when a visitor removes or merges the nodes it visits.

    Document::root

    fn Document::root(self : Document) -> Element?

    The root <svg> element, if any.

    Document::to_repr

    Document::to_string

    fn Document::to_string(self : Document, options? : SerializeOptions) -> String

    Serialize a document back to SVG text.

    Element

    pub(all) struct Element {
    name : String
    attrs : Map[String, String]
    children : Array[Node]
    } derive(
    Debug
    )

    An element with its tag name, attributes and child nodes. Plugins mutate elements in place; name is mutable so shapes can be turned into paths.

    Element::elements

    fn Element::elements(self : Element) -> Array[Element]

    Child elements only (skipping text and comments).

    Element::get

    fn Element::get(self : Element, name : String) -> String?

    Attribute value by name.

    Element::has

    fn Element::has(self : Element, name : String) -> Bool

    Whether the attribute is present.

    Element::new

    fn Element::new(name : String, attrs? : Map[String, String], children? : Array[Node]) -> Element

    Create an element; attributes and children default to empty.

    Element::remove

    fn Element::remove(self : Element, name : String) -> Unit

    Remove an attribute if present.

    Element::set

    fn Element::set(self : Element, name : String, value : String) -> Unit

    Set (or append) an attribute.

    Element::to_repr

    Element::to_string

    fn Element::to_string(self : Element, options? : SerializeOptions) -> String

    Serialize a single element (and its subtree).

    Node

    pub(all) enum Node {
    Element(Element)
    Text(String)
    Comment(String)
    CData(String)
    Doctype(String)
    ProcInst(String, String)
    } derive(
    Debug
    )

    One node of the tree. Text is stored decoded (entities resolved); comments, CDATA, doctype and processing instructions keep their raw body.

    Node::to_repr

    SerializeOptions

    pub(all) struct SerializeOptions {
    pretty : Bool
    prolog : Bool
    } derive(
    Debug
    )

    How Document::to_string prints: compact or indented, with or without the XML prolog.

    SerializeOptions::default

    Compact output including the prolog.

    parse

    fn parse(source : String) -> Document raise ParseError

    Parse an SVG/XML document.