无法加载文件 [英] Failed to load the file
本文介绍了无法加载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个xml文件,我必须加载一些样式表文件,但加载样式表文件时抛出错误
我尝试过:
I have created an xml file and i have to load the some stylesheetfile but its throwing error while loading style sheet file
What I have tried:
MSXML::IXMLDOMDocumentPtr loadXML;
m_hr = loadXML.CreateInstance(__uuidof(DOMDocument));
if (loadXML->load(variant_t(_T("Style.xsl"))) == VARIANT_FALSE)
{
return false; // returning false some times
}
xsl文件包含
xsl file contain
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
推荐答案
当前工作目录不是时,使用不带路径的文件名可能会失败与创建文件时相同。
要知道出了什么问题,请使用 IXMLDOMDocument :: load [ ^ ]函数接受两个参数并返回HRESULT
可用于检索错误消息。
Using a file name without path may fail when the current working directory is not the same as when creating the file.
To know what went wrong use the IXMLDOMDocument::load[^] function that accepts two parameters and returns anHRESULT
which can be used to retrieve an error message.
检查load()
失败时提供的错误信息:
Check the error information provided whenload()
fails:
if (loadXML->load(variant_t(_T("Style.xsl"))) == VARIANT_FALSE)
{
IXMLDOMParseErrorPtr errPtr = loadXML->GetparseError();
_bstr_t bstrErr(errPtr->reason);
printf("Error:\n");
printf("Code = 0x%x\n", errPtr->errorCode);
printf("Source = Line : %ld; Char : %ld\n", errPtr->line, errPtr->linepos);
printf("Error Description = %s\n", (char*)bstrErr);
return false; // returning false some times
}
这篇关于无法加载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文