本文整理汇总了C++中xml_node::add_child方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::add_child方法的具体用法?C++ xml_node::add_child怎么用?C++ xml_node::add_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml_node
的用法示例。
在下文中一共展示了xml_node::add_child方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: populate_tree
void populate_tree(rapidxml::xml_node<char> *cur_node, xml_node &node)
{
switch (cur_node->type())
{
case rapidxml::node_element:
{
xml_node &new_node = node.add_child((char *)cur_node->name(), 0, false);
// Copy attributes
for (rapidxml::xml_attribute<char> *attr = cur_node->first_attribute();
attr; attr = attr->next_attribute())
{
new_node.add_attribute(attr->name(), attr->value());
}
// Copy children
for (rapidxml::xml_node<char> *child = cur_node->first_node();
child; child = child->next_sibling())
{
populate_tree(child, new_node);
}
}
break;
// Data nodes
case rapidxml::node_data:
case rapidxml::node_cdata:
{
node.add_child(cur_node->value(), 0, true);
}
break;
default:
break;
}
}
示例2: populate_tree
void populate_tree(xmlNode *cur_node, xml_node &node)
{
for (; cur_node; cur_node = cur_node->next )
{
switch (cur_node->type)
{
case XML_ELEMENT_NODE:
{
xml_node &new_node = node.add_child((const char *)cur_node->name, cur_node->line, false);
append_attributes(cur_node->properties, new_node);
populate_tree(cur_node->children, new_node);
}
break;
case XML_TEXT_NODE:
{
std::string trimmed((const char*)cur_node->content);
mapnik::util::trim(trimmed);
if (trimmed.empty()) break; //Don't add empty text nodes
node.add_child(trimmed, cur_node->line, true);
}
break;
case XML_COMMENT_NODE:
break;
default:
break;
}
}
}
示例3: populate_tree
void populate_tree(rapidxml::xml_node<char> *cur_node, xml_node &node)
{
switch (cur_node->type())
{
case rapidxml::node_element:
{
xml_node &new_node = node.add_child((char *)cur_node->name(), 0, false);
// Copy attributes
for (rapidxml::xml_attribute<char> *attr = cur_node->first_attribute();
attr; attr = attr->next_attribute())
{
new_node.add_attribute(attr->name(), attr->value());
}
// Copy children
for (rapidxml::xml_node<char> *child = cur_node->first_node();
child; child = child->next_sibling())
{
populate_tree(child, new_node);
}
}
break;
// Data nodes
case rapidxml::node_data:
case rapidxml::node_cdata:
{
std::string trimmed(cur_node->value());
mapnik::util::trim(trimmed);
if (trimmed.empty()) break; //Don't add empty text nodes
node.add_child(trimmed, 0, true);
}
break;
default:
break;
}
}