comparison dep/pugixml/docs/samples/xpath_error.cpp @ 367:8d45d892be88 default tip

*: instead of pugixml, use Qt XML features this means we have one extra Qt dependency though...
author Paper <paper@tflc.us>
date Sun, 17 Nov 2024 22:55:47 -0500
parents 886f66775f31
children
comparison
equal deleted inserted replaced
366:886f66775f31 367:8d45d892be88
1 #include "pugixml.hpp"
2
3 #include <iostream>
4
5 int 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