From 42bcf3566b0d942802599b199b09170c86f34b1e Mon Sep 17 00:00:00 2001 From: jez Date: Sun, 13 Sep 2009 17:41:34 +0100 Subject: [PATCH] XGrep example output non-nodeset results now too --- examples/XPath/xgrep.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/examples/XPath/xgrep.cpp b/examples/XPath/xgrep.cpp index a1f2413b..4903df3a 100644 --- a/examples/XPath/xgrep.cpp +++ b/examples/XPath/xgrep.cpp @@ -55,19 +55,23 @@ int main(int argc, char* argv[]) // doc.normalize(); Arabica::XPath::XPathValuePtr result; result = xpath->evaluate(doc); - if(result->asBool()) + + std::cout << file << std::endl; + switch(result->type()) { - std::cout << file << std::endl; - if(result->type() == Arabica::XPath::NODE_SET) - { - const Arabica::XPath::NodeSet& ns = result->asNodeSet(); - for(unsigned int i = 0; i < ns.size(); ++i) + case Arabica::XPath::NODE_SET: { - Arabica::DOM::Node n = ns[i]; - std::cout << n << std::endl; - } - } // if .. - } // if ... + const Arabica::XPath::NodeSet& ns = result->asNodeSet(); + for(unsigned int i = 0; i < ns.size(); ++i) + { + Arabica::DOM::Node n = ns[i]; + std::cout << n << std::endl; + } + } + break; + default: + std::cout << result->asString() << std::endl; + } // switch } else {