DOMDocument LoadXML失败
程序中如果不进行文件操作 LoadXML 成功
如果程序中进行文件操作 LoadXML 失败 fopen的返回值总是空
int DOMDocument::LoadXML(MLPCSTR pathXML)
{
int ret = 0;
char *xmlBuffer = NULL;
FILE *pf = fopen(pathXML, "rb");
if (!pf)
{
return -1;
}
fpos_t pos;
if (fseek(pf, 0, SEEK_END))
{
fclose(pf);
return -1;
}
if (fgetpos(pf, &pos))
{
fclose(pf);
return -1;
}
if (pos <= 0)
{
fclose(pf);
return -1;
}
xmlBuffer = new char[pos];
assert(xmlBuffer);
if (!xmlBuffer)
{
fclose(pf);
delete[] xmlBuffer;
return -1;
}
rewind(pf);
fread(xmlBuffer, pos, 1, pf);
fclose(pf);
ret = LoadXML(xmlBuffer, pos);
delete[] xmlBuffer;
return ret;
}
[解决办法]
你是不是已经把那个文件打开了没关啊
[解决办法]
Each of these functions returns a pointer to the open file. A null pointer value indicates an error. If filename or mode is NULL or an empty string, these functions trigger the invalid parameter handler, as described in Parameter Validation. If execution is allowed to continue, these functions return NULL and set errno to EINVAL.
See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these, and other, error codes.
[解决办法]
pathXML 是全路径?