Possible Duplicate:
rapidxml: how to iterate through nodes? Leaves out last sibling
Im trying to reas some information from a XML file using rapidXML but cant get it to work.
The XML file looks like this:
<MODESMESSAGE>
<DATETIME>20070622141943</DATETIME>
<MODES>400F2B</MODES>
<CALLSIGN>BAW134</CALLSIGN>
<ALTITUDE>120300</ALTITUDE>
<GROUNDSPEED>451</GROUNDSPEED>
<TRACK>234</TRACK>
<VRATE>0</VRATE>
<AIRSPEED></AIRSPEED>
<LATITUDE>-14.1102</LATITUDE>
<LONGITUDE>-31.5789</LONGITUDE>
</MODESMESSAGE>
And this is how my code looks like
#include <iostream>
#include <cstdlib>
#include "rapidxml.hpp"
#include <iostream>
#include <fstream>
#include <vector>
using namespace rapidxml;
using namespace std;
xml_document<> doc; // character type defaults to char
int main(){
ifstream myfile("test.xml");
xml_document<> doc;
vector<char> buffer((istreambuf_iterator<char>(myfile)), istreambuf_iterator<char>( ));
buffer.push_back('\0');
doc.parse<0>(&buffer[0]);
xml_node<> *node = doc.first_node();
xml_attribute<> *att = node->first_attribute();
cout << node->name();
cout << att->name();
}
I can compile the program but when I run it it just stops working. I can get the first node(MODEMESSAGE) but cant get the the rest of them, ie DATETIME or MODES.
What should I do?