我对 rapidxml 有问题。下面的代码给了我输出: http: //pastebin.com/352MxuQY
但是当我删除循环或“{}”时,我正在附加节点,我得到了很好的输出: http: //pastebin.com/H0YQGwV1
为什么会这样?
rapidxml::xml_document<> andDoc;
ifstream andfile(PATH+XMLNAME);
vector<char> buffer((istreambuf_iterator<char>(andfile)), istreambuf_iterator<char>( ));
buffer.push_back('\0');
cout<<&buffer[0]<<endl; 
andDoc.parse<0>(&buffer[0]); 
xml_node<>* cos = andDoc.first_node("Data")->first_node("Classifiers");
xml_node<>* klda = andDoc.first_node("Data")->first_node("Kldas");
for(int i=0;i<1;i++)
{
    rapidxml::xml_document<> doc;
    ifstream myfile(cPATH+"0\\c.xml");
    vector<char> buffer2((istreambuf_iterator<char>(myfile)), istreambuf_iterator<char>( ));
    buffer2.push_back('\0');
    cout<<&buffer2[0]<<endl; 
    doc.parse<0>(&buffer2[0]); 
    xml_node<>* cl = doc.first_node();
    xml_node<>* asd = doc.clone_node(cl);
    cos->append_node(asd);
    myfile.close();
}
std::ofstream file(PATH+XMLNAME);
if (file.is_open())
{
    file.clear();
    file << andDoc;
    file.close();
}