diff options
Diffstat (limited to 'src/xml')
-rw-r--r-- | src/xml/element.rs | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/xml/element.rs b/src/xml/element.rs index b778dac..91e4130 100644 --- a/src/xml/element.rs +++ b/src/xml/element.rs @@ -24,26 +24,6 @@ impl Elements }) } - pub fn get_first_tagged_with_name_and_attr( - &self, - tag_name: &str, - attribute: &Attribute, - ) -> Option<&Tagged> - { - self.elements.iter().find_map(|element| match element { - Element::Tagged(tagged_element) - if tagged_element.name == tag_name - && tagged_element - .attributes - .iter() - .any(|attr| attr == attribute) => - { - Some(tagged_element) - } - _ => None, - }) - } - pub fn get_all_tagged_elements(&self) -> Vec<&Tagged> { self.elements @@ -68,6 +48,26 @@ impl Elements .collect() } + pub fn get_all_tagged_with_name_and_attr( + &self, + tag_name: &str, + attr_is_match: fn(&Attribute) -> bool, + ) -> Vec<&Tagged> + { + self.elements + .iter() + .filter_map(|element| match element { + Element::Tagged(tagged_element) + if tagged_element.name == tag_name + && tagged_element.attributes.iter().any(attr_is_match) => + { + Some(tagged_element) + } + _ => None, + }) + .collect() + } + pub fn get_first_text_element(&self) -> Option<&String> { self.elements.iter().find_map(|element| match element { |