parse_first_matching_element/
parse_first_matching_element.rs

1//! This example demonstrates how to parse the first element that matches the given tag name.
2
3use std::fs::File;
4
5use nom_xml::{io::read_file, Document};
6
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let mut file = File::open("examples/TheExpanseSeries.xml")?;
9    let data = read_file(&mut file)?;
10    let (_, doc) = Document::parse_element_by_tag_name(&data, "book", &None)?;
11    println!("{doc:?}");
12    Ok(())
13}