How to store the node of an xml file in a string array and then to a structure in C++ -


i have xml file looks :-

disp.xml:

<car> <car1>     <feature1>50</feature1>     <feature2>100</feature2>     <feature3>10</feature3> </car1> <car2>     <feature1>100</feature1>     <feature2>100</feature2>     <feature3>10</feature3> </car2> <car3>     <feature1>500</feature1>     <feature2>0</feature2>     <feature3>10</feature3> </car3> <car4>     <feature1>1000</feature1>     <feature2>0</feature2>     <feature3>0</feature3> </car4> </car> 

code xml reading :-

xmldocument^ xdoc = gcnew xmldocument(); string^ xpath =  ---path of file xdoc->load(xpath); xmlnodelist^ nodes1 = xdoc->getelementsbytagname("car"); xmlnodelist^ car1 = xdoc->getelementsbytagname("car1"); xmlnodelist^ car1 = xdoc->getelementsbytagname("car2");  each (xmlnode^ node1 in nodes1)  {               each(xmlnode^ca1 in car1)     {         feature1= ca1->childnodes[1]->childnodes[0]->value->tostring();          feature2= ca1->childnodes[2]->childnodes[0]->value->tostring();          feature3= ca1->childnodes[3]->childnodes[0]->value->tostring();      } } 

i have structure

example :-

struct car1   { std::string feature1; std::string feature2; std::string feature3; } 

similarly have other structure too.

i need read nodes(values) of each car , store in car1,car2,car3,car4 string array ,these string values must later stored in individual structure in c++.

i have within c++ class library .

a lot of research did let me find out read xml data not store in string array , later in individual structure , in c++.

my favourite tool reading xml in c++ http://pugixml.org/

just read values using (or another) library , save them struct


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -