예제 #1
0
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
0
	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
0
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
0
파일: cxml.cpp 프로젝트: Ifsttar/I-Simpa
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;
}