/// Parses the `geogebra.xml` file to produce a polytope.
Parses the `geogebra.xml` file to produce a polytope.
Parses the ` geogebra . xml ` file to produce a polytope .
pub(super) fn parse_xml<T: Float>(xml: &str) -> GgbResult<Concrete<T>> {
    let mut vertices: Vec<Vertex<T>> = Vec::new();
    let mut edges = Vec::new();
    let mut xml = XmlReader::new(xml);
    loop {
        match xml.as_mut().next() {
            // If the document isn't yet over:
            Some(xml_result) => match xml_result {
                // The next XML event to process:
                Ok(xml_event) => {
                    if let XmlEvent::StartElement {
                        name, attributes, ..
                    } = xml_event
                    {
                        let name = name.local_name;
                        if name == "element" {
                            if let Some(el_type) = attribute(&attributes, "type") {
                                // We found a point.
                                if el_type == "point3d" {
                                    vertices.push(xml.read_point(&attributes)?);
                                }
                                // We found an edge.
                                else if el_type == "segment3d" {
                                    if let Ok(edge) = xml.read_edge() {
                                        edges.push(edge);
                                    }
                                }
                            }
                        }
                        /*  "element" => read_edge(&mut xml),
                        "command" => read_face(&mut xml), */
                    }
                }
                // Something went wrong while fetching the next XML event.
                Err(_) => return Err(GgbError::InvalidXml),
            },
            // The file has finished being read. Time for processing!
            None => todo!(),
        }
    }
}
pub ( super ) fn parse_xml < T : Float > ( xml : & str ) -> GgbResult < Concrete < T > > { let mut vertices : Vec < Vertex < T > > = Vec :: new ( ) ; let mut edges = Vec :: new ( ) ; let mut xml = XmlReader :: new ( xml ) ; loop { match xml . as_mut ( ) . next ( ) { // If the document isn't yet over: Some ( xml_result ) => match xml_result { // The next XML event to process: Ok ( xml_event ) => { if let XmlEvent :: StartElement { name , attributes , .. } = xml_event { let name = name . local_name ; if name == " " { if let Some ( el_type ) = attribute ( & attributes , " " ) { // We found a point. if el_type == " " { vertices . push ( xml . read_point ( & attributes ) ? ) ; } // We found an edge. else if el_type == " " { if let Ok ( edge ) = xml . read_edge ( ) { edges . push ( edge ) ; } } } } /*  "element" => read_edge(&mut xml),
                        "command" => read_face(&mut xml), */ } } // Something went wrong while fetching the next XML event. Err ( _ ) => return Err ( GgbError :: InvalidXml ) , } , // The file has finished being read. Time for processing! None => todo ! ( ) , } } }
Parses the `geogebra.xml` file to produce a polytope.
Parses the ` geogebra . xml ` file to produce a polytope .
xml
&str