示例#1
0
	void XmlTree (std::ostream & out)
	{
		XML::Tree tree;
		XML::Node * root = tree.SetRoot ("UnitTest");
		std::auto_ptr<XML::Node> child1 (new XML::Node ("child"));
		child1->AddAttribute ("num", "1");
		child1->AddTransformAttribute ("level", "1");
		child1->AddTransformAttribute ("upperExamples", 
				"some upper chars: А, ▓, ├ or нт and finally Ш.");
		child1->AddTransformText ("This text contains all 5 special characters:\n"
			"ampersand: &, quotation mark: \", apostrophe: ', less than: < "
			"and greater than char: >.");
		root->AddChild (child1);

		root->AddText ("This is my next child");

		XML::Node * node = root->AddChild ("child");
		node->AddAttribute ("num", 2);
		node->AddAttribute ("level", 1);
		XML::Node * grandChild = node->AddEmptyChild ("Grandchild");
		grandChild->AddAttribute ("age", 2);
		tree.Write (out);

		XML::Node const * firstChild = *tree.GetRoot ()->FirstChild ();
		out << "\n\nTransform back upper-ascii characters: " 
			<< firstChild->GetTransformAttribValue ("upperExamples") << std::endl;
		out << "\nTransform back the text: " 
			<< (*firstChild->FirstChild ())->GetTransformAttribValue ("Text") << std::endl;
	}
示例#2
0
void gtkui_cheats_save() {
	// Save the cheat list
	std::ofstream cheatfile(nstpaths.cheatpath, std::ifstream::out|std::ifstream::binary);
	
	if (cheatfile.is_open()) {
		
		GtkTreeModel *model;
		model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
		
		saveroot = (savexml.GetRoot());
		
		saveroot = savexml.Create( L"cheats" );
		saveroot.AddAttribute( L"version", L"1.0" );
		
		gtk_tree_model_foreach(GTK_TREE_MODEL(model), gtkui_cheats_write_list, NULL);
		
		savexml.Write(saveroot, cheatfile);
		cheatfile.close();
	}
	else { return; }
}