Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
cbpporter is currently offline  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 #46692 is a reply to message #46654] Wed, 13 July 2016 11:46 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

Use Xmlize function and .List("xxx","yyy",zzz) in it for Vectors and Arrays.

SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
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 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
sergeynikitin wrote on Wed, 13 July 2016 12:46
Use 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.
Previous Topic: Accept example in Tutorial
Next Topic: Debug does not work in Rosa Linux Fresh R8
Goto Forum:
  


Current Time: Thu Mar 28 11:42:57 CET 2024

Total time taken to generate the page: 0.01522 seconds