I have a simple XML file but large. Let's say
<products>
<product_id>98667</product_id>
<name>Hiking Boots</name>
<price>34.99</price>
<product_id>10123</product_id>
<name>Work Gloves</name>
<price>12.99</price>
<product_id>15773</product_id>
<name>Belt</name>
<price>14.99</price>
</products>
I want to write the data of the entire file(say 500 entries) to a tab delimited text file. To understand the process even better, lets say I only want to write the products name and products price. I could not see where the typical TinyXml tutorials were covering this type of write.
My code:
void MyProducts::writeProducts(const char *pFilename) {
TiXmlDocument doc(pFilename);
bool loadOkay = doc.LoadFile();
if (loadOkay) {
cout<<"The file loaded"<<endl;
cout<<pFilename<<endl;
cout<<doc<<endl;
}
else {
cout<<"Failed to load file \"%s\"\n"<< pFilename<<endl;
}
} // end function
I'm not sure if I want to parse line by line like a normal file or if that even does any good with this api. I can print the entire contents of doc so I know the file is loading. Any help is appreciated. I'm sure its just a matter of knowing what function calls to make.