Home » Community » Newbie corner » How to store a vector to an XML file with named items?
How to store a vector to an XML file with named items? [message #46654] |
Thu, 23 June 2016 15:20 |
cbpporter
Messages: 1401 Registered: September 2007
|
Ultimate Contributor |
|
|
I'm storing a Vector to an XML like this:
StoreAsXMLFile(methods, "methods", curDir + "buildMethods.xml");
It works fine, but I get a structure with a parent "methods" and children called "item. I would like them to be "method".
And the same thing for LoadFromXMLFile obviously.
Thank you!
|
|
|
|
Re: How to store a vector to an XML file with named items? [message #46812 is a reply to message #46692] |
Tue, 16 August 2016 11:03 |
cbpporter
Messages: 1401 Registered: September 2007
|
Ultimate Contributor |
|
|
sergeynikitin wrote on Wed, 13 July 2016 12:46Use Xmlize function and .List("xxx","yyy",zzz) in it for Vectors and Arrays.
Thank you!
I had to wait until next release to update the format.
But I still can't manage to get it to work.
StoreAsXMLFile(methods, "methods", curDir + "buildMethods.xml");
The code above created an xml with a root "methods" and items called "item".
I tried this instead:
class BuilMethodXml {
public:
BuilMethodXml(Vector<BuildMethod>& meth): methods(meth) {
}
void Xmlize(XmlIO& xml) {
xml.List("methods", "method", methods);
}
private:
Vector<BuildMethod>& methods;
};
BuilMethodXml m(methods);
StoreAsXMLFile(m, "methods", curDir + "buildMethods.xml");
This doesn't work, because it creates a root called "methods" with a tag methods in it and items called "method".
I guess I need to give up on Xmlize and manually parse the Xml.
|
|
|
Goto Forum:
Current Time: Thu Mar 28 11:42:57 CET 2024
Total time taken to generate the page: 0.01522 seconds
|