# HTML reader ## Description This library allows to read HTML strings and convert them to node tree. With the tree it is easier to process data that is stored as HTML/XML file. It is also possible to change the nodes and convert them back into HTML string. ## Current main features - [x] Parse attributes with spaces into multiple strings - [x] Search for nodes that have particular attributes - [x] Change attributes - [x] Change tags name - [x] Edit node's children array - [x] Convert nodes back to HTML - [x] Choose between sharable and owned Nodes (with Arc or without correspondingly) ## Examples ### Load nodes from HTML ``` # use htmldom_read::Node; let html = r#"

Text

"#; // Load with default settings. let nodes = Node::from_html(html, &Default::default()).unwrap().unwrap(); let first_node = nodes.children().get(0).unwrap(); // First node is
assert_eq!("div", first_node.tag_name().unwrap()); let children = first_node.children(); // First child of
is

let first_child = children.get(0).unwrap(); assert_eq!("p", first_child.tag_name().unwrap()); /// The child of

is Text assert_eq!("Text", first_child.children().get(0).unwrap().text().unwrap()); ``` ### Load node with text mixed with children Text that is not mixed load inside the parent node and not as separate child. ``` # use htmldom_read::{Node, LoadSettings}; let html = r#"

Text child more text

"#; let settings = LoadSettings::new().all_text_separately(false); let from = Node::from_html(html, &settings).unwrap().unwrap(); let node = from.children().get(0).unwrap(); let children = node.children(); let first_text = children.get(0).unwrap(); assert_eq!("Text ", first_text.text().unwrap()); let sup = children.get(1).unwrap(); assert_eq!("child", sup.text().unwrap()); let last_text = children.get(2).unwrap(); assert_eq!(" more text", last_text.text().unwrap()); ```