0
我想迭代一個std :: list並將數據寫入DLL中的線程中的xml。但是如果我將更多的對象字段轉儲到XML中,我的XML不會被創建。以下是我的類和用於將數據寫入XML的代碼的詳細信息。將數據寫入DLL中的DLL
class MyClass{
private:
BSTR member1;
BSTR member2;
BSTR member3;
BSTR member4;
public:
MyClass();
~MyClass();
BSTR getMember1()
{
return member1;
}
BSTR getMember2()
{
return member2;
}
BSTR getMember3()
{
return member3;
}
BSTR getMember4()
{
return member4;
}
//Corresponding setters are also present
};
std::list<MyClass> myList;
std::list<MyClass>::iterator iterator;
ofstream outputFile;
outputFile.open("C:\\test.xml",ios::out);
outputFile << "<root>" << endl;
for(iterator=myList.begin();iterator != myList.end();++iterator)
{
//Not working if more values are dumped
USES_CONVERSION;
outputFile << "<Object>" << endl;
outputFile << "<Member1>" << W2A(CString((*iterator).getMember1())) << "</Member1>" << endl;
outputFile << "<Member2>" << W2A(CString((*iterator).getMember2())) << "</Member2>" << endl;
outputFile << "<Member3>" << W2A(CString((*iterator).getMember3())) << "</Member3>" << endl;
outputFile << "<Member4>" << W2A(CString((*iterator).getMember4())) << "</Member4>" << endl;
outputFile << "</Object>" << endl;
}
outputFile << "</root>";
outpuFile.close();
有人能幫我嗎?
你應該總是喜歡使用的libxml2,xmlite或MSXML6,而不是渲染文本XML – rkosegi
@rkosegi感謝您的信息,一些衆所周知的XML庫。我會盡量使用它們。你能指點我一些好的教程嗎? – TechyHarry
http://msdn.microsoft.com/en-us/library/windows/desktop/cc507416%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/桌面/ ms763742%28v = vs.85%29.aspx http://stackoverflow.com/questions/8743879/how-to-generate-xml-file-using-libxml2 – rkosegi