pub fn parse<'a>(input: &'a str) -> IResult<&'a str, Rc<Element<'_>>>
Expand description
transform svg to a Element(AST struct)
return a result.
if transformed successfullly,return a tulp which includes the rest input text and a element;
if transformed Error.return ParseError
ยงExample
use svg_simple_parser::parse;
use std::collections::HashMap;
let svg = r#"
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<circle cx="100" cy="50" r="40" />
</svg>
"#;
let (_, root) = parse(svg).unwrap();
assert_eq!(root.ele_type, "svg");
assert_eq!(*root.attributes.borrow(), HashMap::from([
("xmlns".to_owned(), "http://www.w3.org/2000/svg"),
("version".to_owned(), "1.1"),
]));
let child = &*root.children.borrow()[0];
assert_eq!(child.ele_type, "circle");
assert_eq!(*child.attributes.borrow(), HashMap::from([
("cx".to_owned(), "100"),
("cy".to_owned(), "50"),
("r".to_owned(), "40"),
]));