Read XML data from cin and try to interpret it. You can define fixed structure of your XML tags (with names) or you can have "random" sequences of sub-objects. We use DataXML::to_value() helper function to convert values of attributes.
# include "DataObject.h" # include "XMLStream.h" int main() { DataXML::InputXMLStream xml_is; const DataXML::DataObject& data = xml_is.read(cin); if(!xml_is.success()) { cout << endl << "well, check XML syntax" << endl; return 0; } if(data.name() == "fit") { cout << "this is a fit snaphot: "; string s = data.getAttributeValue("version"); if(s!="") cout << "version " << s; else cout << "no version information"; const DataXML::DataObject* start = data.getChild("start"); if(start) { cout << endl << "starting point"; vector<DataXML::DataObject>::const_iterator par = start->children().begin(); int i = 0; for(;par!=start->children().end(); ++par, ++i) { double val; if( DataXML::to_value(par->getAttributeValue("value"), val) ) { cout << endl << "[" << i << "] " << val; } } } else cout << endl << "no starting point provided"; } else { cout << endl << "sorry, I don't understand this XML tag" << endl; DataXML::OutputXMLStream xml_os(cout); xml_os.write(data); } cout << endl; return 0; }