Typed XML Programming using LEESA

<catalog>
  <book>
    <title>Hamlet</title>
    <price>9.99</price>
    <author>
      <name>William Shakespeare</name>
      <country>England</country>
    </author>
  </book>
  <book>...</book>
...
</catalog>

LEESA expressions embedded in a C++ program XPath expressions
(string encoded)
std::vector<name> author_names =
evaluate(root, catalog() >> book() >> author() >> name());
"/book/author/name/text()"
std::vector<name> author_names =
evaluate(root, catalog() >> DescendantsOf(catalog(), name()));
"//name/text()"
std::vector<name> author_names =
evaluate(root, catalog() >> LevelDescendantsOf(catalog(), _, _, name()));
"/*/*/*/name/text()"
bool from_england(author a){ return a.country() == "England"; }
std::vector<name> author_names =
evaluate(root, catalog() >> DescendantsOf(catalog(), author())
                         >> Select(author(), from_england)
                         >> name());
"//author[country/text() = 'England']/name/text()"
std::vector<tuple<name, country>> tuples =
evaluate(root, catalog() >> book() >> author() >>
         MembersAsTupleOf(author(), make_tuple(name(), country())));
??
MyVisitor visitor;
std::vector<country> countries =
evaluate(root, catalog() >> visitor >>
               book()    >> visitor >>
               author()  >> visitor >>
               country() >> visitor);
??
MyVisitor visitor;
evaluate(root, catalog() >> book() >>
         MembersOf(book(), title() >> visitor, price() >> visitor));
??
MyHierarchicalVisitor visitor;
evaluate(c, catalog()
            >> VisitLeave(catalog(), visitor,
               catalog() >>= book()
               >> VisitLeave(book(), visitor,
                  book() >>= author()
                  >> VisitLeave(author(), visitor,
                     author() >>= born()
                     >> VisitLeave(born(), visitor)))));
??
MyHierarchicalVisitor v;
evaluate(root, catalog() >>
         FullTopDown(catalog(), VisitStrategy(v), LeaveStrategy(v)));
??