本文整理汇总了C++中pugi::xml_node::attributes方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::attributes方法的具体用法?C++ xml_node::attributes怎么用?C++ xml_node::attributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_node
的用法示例。
在下文中一共展示了xml_node::attributes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findSimilarNode
static pugi::xml_node findSimilarNode(pugi::xml_node searchNode, pugi::xml_node searchRoot, unsigned maxDistance)
{
std::string searchNodeName = searchNode.name();
pugi::xml_node match;
// Examine children of searchRoot that have matching names to searchNode
unsigned i = 0;
pugi::xml_node child = searchRoot.first_child();
for (; child && i < maxDistance && !match; child = child.next_sibling(), i++) {
// Ignore nodes with non-matching names
if (searchNodeName != child.name())
continue;
// Assume child is a match, until shown otherwise
match = child;
// Check that all attributes of searchNode match the child node's attributes
for (pugi::xml_attribute attr : searchNode.attributes()) {
std::string searchNodeAttr = attr.value();
std::string matchAttr = child.attribute(attr.name()).value();
if (searchNodeAttr != matchAttr) {
match = pugi::xml_node();
break;
}
}
}
return match;
}
示例2: AddAttributes
void XMLFileParser::AddAttributes(XMLContainer & element, const pugi::xml_node & node)
{
auto attributes = node.attributes();
for(auto attribute : attributes)
{
element.GetAttributes().insert(
std::make_pair<tstring, tstring>(
star::string_cast<tstring>(attribute.name()),
star::string_cast<tstring>(attribute.value())));
}
}
示例3: CopyXmlNode
void XmlTools::CopyXmlNode(const pugi::xml_node& srcNode, pugi::xml_node& dstNode)
{
for (const pugi::xml_attribute& attr : srcNode.attributes())
{
auto attrCopy = dstNode.append_attribute(attr.name());
attrCopy.set_value(attr.value());
}
for (const pugi::xml_node& node : srcNode.children())
{
auto nodeCopy = dstNode.append_child(node.name());
CopyXmlNode(node, nodeCopy);
}
auto nodeText = srcNode.text();
dstNode.text().set(nodeText.as_string());
}
示例4: AddProperty
CXmlNode::CXmlNode(CXmlNode* _parent , const pugi::xml_node& rowData )
{
this->nodeData.parent=NULL;
if(rowData!=NULL)
{
nodeData.nodeName=rowData.name();
for (auto &&item : rowData.attributes()) {
AddProperty(item.name(), item.value());
}
for (auto &&child : rowData.children()) {
CXmlNode* newChild = new CXmlNode(this, child);
this->nodeData.children.push_back(newChild);
}
}
this->nodeData.parent=_parent;
}