Preparing for debian package
[ACL.git] / test / xml_node.cpp
1 /*******************************************************
2  *  Unit test for the xml_node class
3  *
4  * test xml node access
5  ******************************************************
6  *
7  */
8
9 #include "xml.h"
10 #include <assert.h>
11
12 int main()
13 {
14    xml    doc;
15
16    const char xml_file[] = "xml_test01.xml";
17
18    std::cout << "Reading XML file " << xml_file << "\n";
19
20    doc.ParseFile("xml_test01.xml");
21
22    xml_node root_node(doc);
23
24    std::cout << "Root element is " << root_node.name() << "\n";
25    std::cout << "Root node type is " << root_node.type() << "\n";
26    assert(root_node.name() == "doc");
27
28    int i;
29    xml_node child;
30
31    root_node = root_node[1]; // The book element
32    child = root_node[0];
33    for (i = 0; child.is_a_node(); i++)
34    {
35       child = root_node[i];
36       std::cout << "Node " << i << " type is " << child.type() << "\n";
37       std::cout << "Node " << i << " name is " << child.name() << "\n";
38    }
39
40    return 0;
41 }
42