Skip to content
RainbowLand edited this page Mar 31, 2017 · 1 revision

Add an easier way to use tinyxml2 to construct xml document same as std::map.

#include "tinyxml2++.h"
int main(int argc, char* argv[])
{
	tinyxml2::XMLPPDocument doc("1.0","utf-8");

	doc["root"]["name"] = "archer";
	doc["root"]["age"] = 10;
	doc["root"]["info"]["tel"] = "1000229";

	cout << (const char*)doc << endl;

	return 0;
}

output :
<?xml version="1.0" encoding="utf-8"?>
<root>
	<name>archer</name>
	<age>10</age>
	<info>
		<tel>1000229</tel>
	</info>
</root>

Clone this wiki locally