Macro vtd_xml::vtd_for_children [] [src]

macro_rules! vtd_for_children {
    ($vn: ident, $tag: expr, $default: expr, $code: block) => { ... };
    ($vn: ident, $tag: expr, $code: block) => { ... };
}

Loop over the immediate children with the given tag name.

The loop might return a value using the break value mechanics. For example:

let xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo>bar</foo>";
let mut vg = VtdGen::new();
vg.parse_vec (false, Rc::new (xml.into()), 0, xml.len());
let mut vn = VtdNav::new (&mut vg);
let first_bar = vtd_for_children! (vn, "foo", String::new(), {break vn.text().clone()});
  • vn - VtdNav instance. Children are searched for immediately under the current position.
  • tag - The name of the child XML tag. We skip any children not matching the tag name.
  • default - Default return value of the loop. Set it to () if you're not returning a value.
  • code - A block of code that is run for every child matching the tag.