Skip to content

Commit 91e26d1

Browse files
author
Jayce Fayne
committed
fix dom manipulation example
1 parent 4cb7107 commit 91e26d1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scraper/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,11 @@ let html = "<html><body>hello<p class=\"hello\">REMOVE ME</p></body></html>";
140140
let selector = Selector::parse(".hello").unwrap();
141141
let mut document = Html::parse_document(html);
142142
let node_ids: Vec<_> = document.select(&selector).map(|x| x.id()).collect();
143+
let tree = HtmlTreeSink::new(document);
143144
for id in node_ids {
144-
document.remove_from_parent(&id);
145+
tree.remove_from_parent(&id);
145146
}
147+
let document = tree.finish();
146148
assert_eq!(document.html(), "<html><head></head><body>hello</body></html>");
147149
```
148150

0 commit comments

Comments
 (0)