Closed sp3d closed 6 years ago
You're right, it would be nice to have a function Node::attributes()
that does this. Until then you can do it in a somewhat hacky way:
let node = document.find(Class("js-gps-track")).next().unwrap();
match node.data() {
&select::node::Data::Element(_, ref attrs) => {
for &(ref name, ref value) in attrs {
println!("{} = {}", name.local, value);
}
},
_ => {}
}
href = http://chat.stackoverflow.com
class = js-gps-track
data-gps-track = site_switcher.click({ item_type:6 })
As long as it's possible with the current API this isn't a huge deal (though a convenience function would be nice. Thanks for the help!
Oops, didn't mean to close.
You can now do:
for (name, value) in node.attrs() {
println!("{} = {}", name, value);
}
Is it possible to access attributes using select.rs without knowing their names beforehand? If not, could an interface for iterating over (attr name, attr value) pairs be added?