[libxml++] Putting values in a decent data structure



Hello everyone,

I want to read a XML file and stick into a data structure of my own; I
need bits of it across my whole project, so passing around NodeSets
seems to be a no-go and not the appropriate option, but maybe I'm wrong.

In short my problem looks like this:

XML file:
<aaa>
   <bbb>
      <ccc>bla</ccc>
      <ddd>
         <eee>1</eee>
         <eee>2</eee>
         ...
      </ddd>
   </bbb>
   <bbb>
      <ccc>blah</ccc>
      <ddd>
         <eee>7</eee>
         <eee>8</eee>
         ...
      </ddd>
   </bbb>
</aaa>

data structure:
struct t_aaa
{
   std::list<t_bbb> bbb;
};
struct t_bbb
{
   std::string ccc;
   t_ddd ddd;
};
struct t_ddd
{
   std::list<int> eee;
};

Of course I don't DOM-parse stupid aaa-bbb-files to bug you; the real
file is http://protosquared.sf.net/protosquared.conf.xml (and
http://protosquared.sf.net/protosquared.conf.xsd if you like) - I need
the <datasources>-section to be put into
http://protosquared.sf.net/datastructures.hh.

After that utterly exhausting talk, now my question: How do I do it? 

I libxml2-xml-schema-validated it, got the appropriate NodeSet via 
   ns = rootNode->find("//datasource/descendant::*"); 
and begin iterating over it: 
   for(xmlpp::NodeSet::iterator it=ns.begin();it!=ns.end();++it)

The problem is, to know when which ddd-list is finished, to add it to
the bbb one. Maybe there's a clever trick and I don't see or maybe my
"design" is crap. I even appreciate flames, so thanks alot in advance.

Have a nice day,
 Daniel








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]