本文整理汇总了C++中xml::Node::AddChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Node::AddChild方法的具体用法?C++ Node::AddChild怎么用?C++ Node::AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml::Node
的用法示例。
在下文中一共展示了Node::AddChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XmlTree
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:
void Configuration::Node::Save(Xml::Node node,wcstring const key) const
{
NST_ASSERT( node && (!key || *key) );
if (map.empty())
{
if (key)
node.AddChild( key, string.Ptr() );
}
else
{
if (key)
node = node.AddChild( key );
for (Map::const_iterator it(map.begin()), end(map.end()); it != end; ++it)
it->second.Save( node, it->first.Ptr() );
}
}
示例3: gtkui_cheats_write_list
gboolean gtkui_cheats_write_list(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer userdata) {
// Write entries to the cheat file
bool enabled;
gchar *ggcode, *parcode, *rawcode, *description;
char buf[9];
wchar_t wbuf[9];
gtk_tree_model_get(model, iter, 0, &enabled, 1, &ggcode, 2, &parcode, 3, &rawcode, 4, &description, -1);
Xml::Node node(saveroot.AddChild(L"cheat"));
node.AddAttribute(L"enabled", enabled ? L"1" : L"0");
if (ggcode) {
snprintf(buf, sizeof(buf), "%s", ggcode);
mbstowcs(wbuf, buf, 9);
node.AddChild(L"genie", wbuf);
}
if (parcode) {
snprintf(buf, sizeof(buf), "%s", parcode);
mbstowcs(wbuf, buf, 9);
node.AddChild(L"rocky", wbuf);
}
if (rawcode) {
snprintf(buf, sizeof(buf), "0x%c%c%c%c", rawcode[0], rawcode[1], rawcode[2], rawcode[3]);
mbstowcs(wbuf, buf, 9);
node.AddChild(L"address", wbuf);
snprintf(buf, sizeof(buf), "0x%c%c", rawcode[5], rawcode[6]);
mbstowcs(wbuf, buf, 9);
node.AddChild(L"value", wbuf);
snprintf(buf, sizeof(buf), "0x%c%c", rawcode[8], rawcode[9]);
mbstowcs(wbuf, buf, 9);
node.AddChild(L"compare", wbuf);
}
if (description) {
char descbuf[512];
wchar_t wdescbuf[512];
snprintf(descbuf, sizeof(descbuf), "%s", description);
mbstowcs(wdescbuf, descbuf, 512);
node.AddChild(L"description", wdescbuf);
}
g_free(ggcode);
g_free(parcode);
g_free(rawcode);
g_free(description);
return false;
}