本文整理汇总了C++中DomElement::append_child方法的典型用法代码示例。如果您正苦于以下问题:C++ DomElement::append_child方法的具体用法?C++ DomElement::append_child怎么用?C++ DomElement::append_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomElement
的用法示例。
在下文中一共展示了DomElement::append_child方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_child_string_ns
void DomElement::set_child_string_ns(const DomString &namespace_uri, const DomString &qualified_name, const DomString &value)
{
DomString local_name;
DomString::size_type pos = qualified_name.find(L':');
if (pos != DomString::npos)
local_name = qualified_name.substr(pos + 1);
else
local_name = qualified_name;
DomElement element = named_item_ns(namespace_uri, local_name).to_element();
if (element.is_null())
{
element = get_owner_document().create_element_ns(namespace_uri, qualified_name);
append_child(element);
}
DomText dom_text = get_owner_document().create_text_node(value);
if (element.get_first_child().is_text())
{
DomNode temp_domnode = element.get_first_child();
replace_child(dom_text, temp_domnode);
}
else
{
element.append_child(dom_text);
}
}
示例2: save_item
void Project::save_item(DomElement dom_parent, ProjectItem *item)
{
DomElement dom_item;
if (dynamic_cast<ProjectFolderItem*>(item))
{
ProjectFolderItem *folder_item = dynamic_cast<ProjectFolderItem*>(item);
dom_item = dom_parent.get_owner_document().create_element("folder");
dom_item.set_child_string("path", folder_item->path);
}
else if (dynamic_cast<ProjectFilterItem*>(item))
{
ProjectFilterItem *filter_item = dynamic_cast<ProjectFilterItem*>(item);
dom_item = dom_parent.get_owner_document().create_element("filter");
dom_item.set_child_string("name", filter_item->name);
}
else if (dynamic_cast<ProjectFileItem*>(item))
{
ProjectFileItem *file_item = dynamic_cast<ProjectFileItem*>(item);
dom_item = dom_parent.get_owner_document().create_element("file");
dom_item.set_child_string("filename", file_item->filename);
}
else
{
throw Exception("Unknown item type");
}
save_item_children(dom_item, item);
dom_parent.append_child(dom_item);
}
示例3: save_item_children
void Project::save_item_children(DomElement dom_parent, ProjectItem *item)
{
if (!item->children().empty())
{
DomElement dom_items = dom_parent.get_owner_document().create_element("items");
for (size_t i = 0; i < item->children().size(); i++)
{
save_item(dom_items, item->children()[i]);
}
dom_parent.append_child(dom_items);
}
}
示例4: set_child_string
void DomElement::set_child_string(const DomString &name, const DomString &value)
{
DomElement element = named_item(name).to_element();
if (element.is_null())
{
element = get_owner_document().create_element(name);
append_child(element);
}
while (!element.get_first_child().is_null())
{
DomNode my_child = element.get_first_child();
element.remove_child(my_child);
}
DomText dom_text = get_owner_document().create_text_node(value);
element.append_child(dom_text);
}