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 » U++ Library support » U++ Core » Xmlize - need help
Xmlize - need help [message #46952] Tue, 27 September 2016 17:47
deep is currently offline  deep
Messages: 227
Registered: July 2011
Location: Bangalore
Experienced Member
Hi,

s = <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE Properties>
<Properties>
		<PROPERTY NAME="Company Name" TYPE="string">My Company 1</PROPERTY>
		<PROPERTY NAME="Company Name" TYPE="string">My Company 2</PROPERTY>
		<PROPERTY NAME="Company Name" TYPE="string">My Company 3</PROPERTY>
		<PROPERTY NAME="Company Name" TYPE="string">My Company 4</PROPERTY>
		<PROPERTY NAME="Company Name" TYPE="string">My Company 5</PROPERTY>
</Properties>


I want to create XML file like this using Xmlize

Code which I am trying. Need help in Xmlize xml declaration

#include <Core/Core.h>

using namespace Upp;

struct RepProperty :  Moveable<RepProperty> {

	String propName;
	String propValue, propType;

	void Xmlize ( XmlIO& xml ) {
		xml ( "PROPERTY" , propValue );
		xml.Attr ( "NAME", propName ).Attr("TYPE", propType);
	}

};

struct test : Moveable<test> {
	Vector<RepProperty> repProp;
	void Xmlize ( XmlIO& xml ) {
		xml ( "PROPERTIES", "PROPERTY", repProp );
	}
};

CONSOLE_APP_MAIN {
	test t;

	for ( int i = 0; i < 5 ; i++ ) {
		RepProperty &r = t.repProp.Add();
		r.propName = "Company Name" ;
		r.propValue = "My Company" ;
		r.propType = "string" ;
	}

	String s = StoreAsXML ( t.repProp , "Properties" );

	DUMP ( s );

}



I get following result.
* 
s = <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE Properties>
<Properties>
	<item NAME="Company Name" TYPE="string">
		<PROPERTY>My Company</PROPERTY>
	</item>
	<item NAME="Company Name" TYPE="string">
		<PROPERTY>My Company</PROPERTY>
	</item>
	<item NAME="Company Name" TYPE="string">
		<PROPERTY>My Company</PROPERTY>
	</item>
	<item NAME="Company Name" TYPE="string">
		<PROPERTY>My Company</PROPERTY>
	</item>
	<item NAME="Company Name" TYPE="string">
		<PROPERTY>My Company</PROPERTY>
	</item>
</Properties>


Actually for this code to compile I done following change in Core/Xmlize.h
	template <class T> XmlIO operator()(const char *tag, T& var);
//	template <class T> XmlIO List(const char *tag, const char *itemtag, T& var);
	template <class T> XmlIO operator()(const char *tag, const char *itemtag, T& var);

	template <class T> XmlIO operator()(const char *tag, T& var, const T& def);
//	template <class T> XmlIO List(const char *tag, const char *itemtag, T& var, const T& def);
	template <class T> XmlIO operator()(const char *tag, const char *itemtag, T& var, const T& def);


Warm Regards

Deepak

[Updated on: Tue, 27 September 2016 17:50]

Report message to a moderator

Previous Topic: HttpRequest issue
Next Topic: Misssing pick in implementation of AMap<K, T, V>::Put(const K& k, T&& x)
Goto Forum:
  


Current Time: Fri Jan 22 16:29:42 CET 2021

Total time taken to generate the page: 0.02943 seconds