[doc]
This commit is contained in:
parent
72f3dbbd7e
commit
6c94881b5a
1 changed files with 9 additions and 8 deletions
|
@ -159,31 +159,32 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Walks the tree and returns every element that has the given name
|
||||||
pub fn find_elems(root: &Element, tag: String) -> Vec<&Element> {
|
pub fn find_elems(root: &Element, searched_name: String) -> Vec<&Element> {
|
||||||
let mut elems: Vec<&Element> = Vec::new();
|
let mut elems: Vec<&Element> = Vec::new();
|
||||||
|
|
||||||
for el in root.children() {
|
for el in root.children() {
|
||||||
if el.name() == tag {
|
if el.name() == searched_name {
|
||||||
elems.push(el);
|
elems.push(el);
|
||||||
} else {
|
} else {
|
||||||
let ret = find_elems(el, tag.clone());
|
let ret = find_elems(el, searched_name.clone());
|
||||||
elems.extend(ret);
|
elems.extend(ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elems
|
elems
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_elem(root: &Element, tag: String) -> Option<&Element> {
|
/// Walks the tree until it finds an elements with the given name
|
||||||
if root.name() == tag {
|
pub fn find_elem(root: &Element, searched_name: String) -> Option<&Element> {
|
||||||
|
if root.name() == searched_name {
|
||||||
return Some(root);
|
return Some(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
for el in root.children() {
|
for el in root.children() {
|
||||||
if el.name() == tag {
|
if el.name() == searched_name {
|
||||||
return Some(el);
|
return Some(el);
|
||||||
} else {
|
} else {
|
||||||
let ret = find_elem(el, tag.clone());
|
let ret = find_elem(el, searched_name.clone());
|
||||||
if ret.is_some() {
|
if ret.is_some() {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue