From d89f6e1c447fc5e7fcd0d6e5a236298323f9596e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 15 May 2007 05:44:06 +0000 Subject: The XPath visitor class is now working --- src/main.cc | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src/main.cc') diff --git a/src/main.cc b/src/main.cc index 8aacfcda..13b02290 100644 --- a/src/main.cc +++ b/src/main.cc @@ -46,10 +46,6 @@ #include #endif -void print_node(ledger::xml::node_t& node) { - node.print(std::cout); -} - static int read_and_report(ledger::report_t * report, int argc, char * argv[], char * envp[]) { @@ -269,25 +265,15 @@ static int read_and_report(ledger::report_t * report, int argc, char * argv[], } else if (verb == "xpath") { std::cout << "XPath parsed:" << std::endl; + xml::xpath_t xpath(*arg); xpath.print(*out, xml_document); *out << std::endl; -#if 1 - try { - xml::xpath_t::path_t path_selection(xpath); - path_selection.visit(xml_document, report, bind(print_node, _1)); - } - catch (...) { - throw; + foreach (xml::node_t * node, xpath.find_all(xml_document, report)) { + node->print(std::cout); + std::cout << std::endl; } -#else - value_t nodelist; - xpath.calc(nodelist, xml_document, report); - - foreach (const value_t& node, nodelist.as_sequence()) - node.as_xml_node()->print(*out); -#endif return 0; } -- cgit v1.2.3