mirror of https://github.com/msfjarvis/adx.git
adx: improve node iteration logic
This commit is contained in:
parent
cd21733bed
commit
35768122e9
|
@ -30,8 +30,14 @@ async fn get_group_index(group: &str) -> Result<String> {
|
|||
// `search_term`.
|
||||
fn filter_groups(doc: Document, search_term: &str) -> Vec<String> {
|
||||
let mut groups = vec![];
|
||||
for i in doc.descendants() {
|
||||
let tag = i.tag_name().name();
|
||||
for node in doc
|
||||
.descendants()
|
||||
// Only keep elements
|
||||
.filter(|node| node.node_type() == NodeType::Element)
|
||||
// Skip the first one since it is junk
|
||||
.skip(1)
|
||||
{
|
||||
let tag = node.tag_name().name();
|
||||
if tag.contains(search_term) {
|
||||
groups.push(tag.to_string());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue