Skip to main content

xml_to_csv

Function xml_to_csv 

Source
pub fn xml_to_csv(xml: &str) -> Result<String, Box<dyn Error>>
Expand description

Converts XML to CSV, extracting the tabular array if present.

Expects the XML to follow <root><item><col>value</col></item></root> (or any single-level root whose single child key holds the rows). Errors if the structure is not tabular.

§Errors

Returns an error if the XML is malformed or not tabular.

§Examples

use sheeter_engine::xml_to_csv;
let csv = xml_to_csv("<root><item><a>1</a></item></root>").unwrap();
assert_eq!(csv, "a\n1\n");