我有一個數組是這樣的:如何從XML獲得字符串中的COM
static WCHAR FilesToShow[][100] = { { L"start.cmd" },{ L"image.xml" }, { L"xyz" }};
,你看到有「XYZ」我有一些獨特的名稱來代替。爲此,我必須讀取image.xml文件。
請你能告訴我該怎麼做。
我寫了這樣的方法:
PRIVATE WCHAR GetSystemName(WCHAR *pName)
{
WCHAR line;
wfstream in("image.xml");
WCHAR tmp;
bool begin_tag = false;
while (getline(in,line))
{
// strip whitespaces from the beginning
for (int i = 0; i < line.length(); i++)
{
if (line[i] == ' ' && tmp.size() == 0)
{
}
else
{
tmp += line[i];
}
}
if (wcswcs(tmp,"<SystemPath>") != NULL)
{
???????? how to get "vikash" from here <SystemPath>C:\Users\rs_user\Documents\RobotStudio\Systems\vikash</SystemPath>
}
else
{
continue;
}
}
return tmp;
}
我得到wfstream,函數getline和line.length()方法例外。 我已經包含fstream.h頭文件,但我認爲它不支持在COM中。
請幫助我如何解決這個問題,而無需解析XML文件。
在上述問題我已經從與vikash或任何動態值陣列替換 「XYZ」。 – user2932395