XGrep example output non-nodeset results now too

This commit is contained in:
jez 2009-09-13 17:41:34 +01:00
parent ef984c7245
commit 42bcf3566b

View file

@ -55,19 +55,23 @@ int main(int argc, char* argv[])
// doc.normalize(); // doc.normalize();
Arabica::XPath::XPathValuePtr<std::string> result; Arabica::XPath::XPathValuePtr<std::string> result;
result = xpath->evaluate(doc); result = xpath->evaluate(doc);
if(result->asBool())
std::cout << file << std::endl;
switch(result->type())
{ {
std::cout << file << std::endl; case Arabica::XPath::NODE_SET:
if(result->type() == Arabica::XPath::NODE_SET)
{
const Arabica::XPath::NodeSet<std::string>& ns = result->asNodeSet();
for(unsigned int i = 0; i < ns.size(); ++i)
{ {
Arabica::DOM::Node<std::string> n = ns[i]; const Arabica::XPath::NodeSet<std::string>& ns = result->asNodeSet();
std::cout << n << std::endl; for(unsigned int i = 0; i < ns.size(); ++i)
} {
} // if .. Arabica::DOM::Node<std::string> n = ns[i];
} // if ... std::cout << n << std::endl;
}
}
break;
default:
std::cout << result->asString() << std::endl;
} // switch
} }
else else
{ {