source: icGREP/icgrep-devel/icgrep/combine/pugixml/docs/samples/xpath_error.cpp @ 5516

Last change on this file since 5516 was 5516, checked in by faldebey, 22 months ago

added combinatorial testing tool

File size: 898 bytes
Line 
1#include "pugixml.hpp"
2
3#include <iostream>
4
5int main()
6{
7    pugi::xml_document doc;
8    if (!doc.load_file("xgconsole.xml")) return -1;
9
10// tag::code[]
11    // Exception is thrown for incorrect query syntax
12    try
13    {
14        doc.select_nodes("//nodes[#true()]");
15    }
16    catch (const pugi::xpath_exception& e)
17    {
18        std::cout << "Select failed: " << e.what() << std::endl;
19    }
20
21    // Exception is thrown for incorrect query semantics
22    try
23    {
24        doc.select_nodes("(123)/next");
25    }
26    catch (const pugi::xpath_exception& e)
27    {
28        std::cout << "Select failed: " << e.what() << std::endl;
29    }
30
31    // Exception is thrown for query with incorrect return type
32    try
33    {
34        doc.select_nodes("123");
35    }
36    catch (const pugi::xpath_exception& e)
37    {
38        std::cout << "Select failed: " << e.what() << std::endl;
39    }
40// end::code[]
41}
42
43// vim:et
Note: See TracBrowser for help on using the repository browser.