Only first character of node name parsed. (RapidXML)

Hello, I think I'm doing something wrong here:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using namespace rapidxml;

    std::string input_xml;
    std::string line;
    std::ifstream in("testtable.xml");

    // read file into input_xml
    while(getline(in,line)){
        std::cout << line << std::endl;
        input_xml += line;
    }

    // Run the RapidXML parser inputting the string that has just been loaded.
    std::vector<char> xml_copy(input_xml.begin(), input_xml.end());
    xml_copy.push_back('\0');
    xml_document<> doc;
    doc.parse<parse_full>(&xml_copy[0]); // Wrong flags here?
    xml_node<> *node = doc.first_node(0);

    while (node != 0){

        std::cout << "Name of node is: " << *node->name()<< "\n"; // <-- Wrong output here.
        node = &(*node->next_sibling()); // Assign a reference of *node's next sibling to the node pointer for the next iteration.
        // If *node has no next sibling, the returned adress will be 0, in which case the looping condidion will return false and stop looping.

    }


testtable.xml
1
2
3
4
5
<?xml version="1.0" ?>
<hstaticwall num_verts="2">
    <vertex x="0.0" y="0.0"/>
    <vertex x="0.0" y="0.0"/>
</hstaticwall>


For some reason, the code above only outputs the first character of the node name ("h" instead of "hstaticwall"). Would anyone be so kind to tell me why?

EDIT: Sorry, it seems like I had to remove the * before node. It's working.
Last edited on
Topic archived. No new replies allowed.