Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

dxml_read_example.cpp

Go to the documentation of this file.
00001 
00012 # include "DataObject.h"
00013 # include "XMLStream.h"
00014 
00015 
00016 int main()
00017 {
00018   DataXML::InputXMLStream xml_is;
00019 
00020   const DataXML::DataObject& data = xml_is.read(cin);
00021 
00022   if(!xml_is.success())
00023     {
00024       cout << endl << "well, check XML syntax" << endl;
00025       return 0;
00026     }
00027 
00028   if(data.name() == "fit")
00029     {
00030       cout << "this is a fit snaphot: ";
00031 
00032       string s = data.getAttributeValue("version");
00033 
00034       if(s!="") cout << "version " << s;
00035       else
00036         cout << "no version information";
00037 
00038       const DataXML::DataObject* start = data.getChild("start");
00039 
00040       if(start)
00041         {      
00042           cout << endl << "starting point";
00043 
00044           vector<DataXML::DataObject>::const_iterator par = start->children().begin();
00045 
00046           int i = 0;
00047 
00048           for(;par!=start->children().end(); ++par, ++i)
00049             {
00050               double val;
00051 
00052               if( DataXML::to_value(par->getAttributeValue("value"), val) )
00053                 {
00054                   cout << endl << "[" << i << "] " << val;
00055                 }
00056             }
00057         }
00058       else
00059         cout << endl << "no starting point provided";
00060     
00061     }
00062   else
00063     {
00064       cout << endl << "sorry, I don't understand this XML tag" << endl;
00065 
00066       DataXML::OutputXMLStream xml_os(cout);
00067       xml_os.write(data); 
00068     }
00069 
00070   cout << endl;
00071 
00072   return 0;
00073 }
00074 

Generated at Tue Jan 28 15:35:28 2003 for DataXML by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001