本文整理汇总了C++中IXMLDOMDocument::get_parseError方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMDocument::get_parseError方法的具体用法?C++ IXMLDOMDocument::get_parseError怎么用?C++ IXMLDOMDocument::get_parseError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXMLDOMDocument
的用法示例。
在下文中一共展示了IXMLDOMDocument::get_parseError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
IXMLDOMDocument *XmlParser::_openFile(const LPWSTR file, XMLERRORDATA *error)
{
if(error)
{
error->errorCode = -1;
error->line = -1;
error->reason = NULL;
}
bool ok = false;
IXMLDOMDocument *x = createAndConfigureInterface();
if(x)
{
VARIANT_BOOL bl;
VARIANT str;
//Выделяем строку.
CWA(oleaut32, VariantInit)(&str);
str.vt = VT_BSTR;
str.bstrVal = CWA(oleaut32, SysAllocString)(file);
if(str.bstrVal != NULL)
{
//Загружаем файл.
if(x->load(str, &bl) == S_OK && bl == VARIANT_TRUE)ok = true;
//Получаем ошибку.
else if(error)
{
IXMLDOMParseError *ierror;
if(x->get_parseError(&ierror) == S_OK)
{
long l;
BSTR reason = NULL;
//Заполняем структуру.
if(ierror->get_errorCode(&l) == S_OK)error->errorCode = l;
if(ierror->get_line(&l) == S_OK)error->line = l;
if(ierror->get_reason(&reason) == S_OK)error->reason = reason;
ierror->Release();
}
}
CWA(oleaut32, VariantClear)(&str);
}
//Объект не создан, освобождаем интерфейс.
if(ok == false)
{
x->Release();
x = NULL;
}
}
return x;
}
示例2: do_CheckXML
int do_CheckXML(lua_State* L)
{
CString strXml = luaL_checkstring(L,1);
HRESULT hr;
IXMLDOMDocument * pXMLDoc;
//...
hr = CoInitialize(NULL);
// Check the return value, hr...
hr = CoCreateInstance(CLSID_DOMDocument30, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument, (void**)&pXMLDoc);
// Check the return value, hr...
VARIANT_BOOL bSuccessful;
pXMLDoc->loadXML(strXml.AllocSysString(),&bSuccessful);
int irez = 0;
if(!bSuccessful)
{
IXMLDOMParseError *pIParseError = NULL;
pXMLDoc->get_parseError(&pIParseError);
long lineNum;
pIParseError->get_line(&lineNum);
long linePos;
pIParseError->get_linepos(&linePos);
BSTR reason;
pIParseError->get_reason(&reason);
lua_pushinteger(L, lineNum);
lua_pushinteger(L, linePos);
lua_pushstring(L, CString(reason));
pIParseError->Release();
pIParseError = NULL;
irez = 3;
}
pXMLDoc->Release();
return irez;
}
示例3: XmlLoadDocumentFromFileEx
/*******************************************************************
XmlLoadDocumentFromFileEx
********************************************************************/
extern "C" HRESULT DAPI XmlLoadDocumentFromFileEx(
__in_z LPCWSTR wzPath,
__in DWORD dwAttributes,
__out IXMLDOMDocument** ppixdDocument
)
{
HRESULT hr = S_OK;
VARIANT varPath;
VARIANT_BOOL vbSuccess = 0;
IXMLDOMDocument* pixd = NULL;
IXMLDOMParseError* pixpe = NULL;
::VariantInit(&varPath);
varPath.vt = VT_BSTR;
varPath.bstrVal = ::SysAllocString(wzPath);
ExitOnNull(varPath.bstrVal, hr, E_OUTOFMEMORY, "failed to allocate bstr for Path in XmlLoadDocumentFromFileEx");
hr = XmlCreateDocument(NULL, &pixd);
if (hr == S_FALSE)
{
hr = E_FAIL;
}
ExitOnFailure(hr, "failed XmlCreateDocument");
if (dwAttributes & XML_LOAD_PRESERVE_WHITESPACE)
{
hr = pixd->put_preserveWhiteSpace(VARIANT_TRUE);
ExitOnFailure(hr, "failed put_preserveWhiteSpace");
}
// Avoid triggering anything external.
hr = pixd->put_validateOnParse(VARIANT_FALSE);
ExitOnFailure(hr, "failed put_validateOnParse");
hr = pixd->put_resolveExternals(VARIANT_FALSE);
ExitOnFailure(hr, "failed put_resolveExternals");
pixd->put_async(VARIANT_FALSE);
hr = pixd->load(varPath, &vbSuccess);
if (S_FALSE == hr)
{
hr = HRESULT_FROM_WIN32(ERROR_OPEN_FAILED);
}
if (FAILED(hr) && S_OK == pixd->get_parseError(&pixpe))
{
XmlReportParseError(pixpe);
}
ExitOnFailure1(hr, "failed to load XML from: %ls", wzPath);
if (ppixdDocument)
{
*ppixdDocument = pixd;
pixd = NULL;
}
hr = S_OK;
LExit:
ReleaseVariant(varPath);
ReleaseObject(pixd);
ReleaseObject(pixpe);
return hr;
}
示例4: XmlLoadDocumentEx
/********************************************************************
XmlLoadDocumentEx -
*********************************************************************/
extern "C" HRESULT DAPI XmlLoadDocumentEx(
__in_z LPCWSTR wzDocument,
__in DWORD dwAttributes,
__out IXMLDOMDocument** ppixdDocument
)
{
HRESULT hr = S_OK;
VARIANT_BOOL vbSuccess = 0;
// RELEASEME
IXMLDOMDocument* pixd = NULL;
IXMLDOMParseError* pixpe = NULL;
BSTR bstrLoad = NULL;
if (!wzDocument || !*wzDocument)
{
hr = E_UNEXPECTED;
ExitOnFailure(hr, "string must be non-null");
}
hr = XmlCreateDocument(NULL, &pixd);
if (hr == S_FALSE)
{
hr = E_FAIL;
}
ExitOnFailure(hr, "failed XmlCreateDocument");
if (dwAttributes & XML_LOAD_PRESERVE_WHITESPACE)
{
hr = pixd->put_preserveWhiteSpace(VARIANT_TRUE);
ExitOnFailure(hr, "failed put_preserveWhiteSpace");
}
// Security issue. Avoid triggering anything external.
hr = pixd->put_validateOnParse(VARIANT_FALSE);
ExitOnFailure(hr, "failed put_validateOnParse");
hr = pixd->put_resolveExternals(VARIANT_FALSE);
ExitOnFailure(hr, "failed put_resolveExternals");
bstrLoad = ::SysAllocString(wzDocument);
ExitOnNull(bstrLoad, hr, E_OUTOFMEMORY, "failed to allocate bstr for Load in XmlLoadDocumentEx");
hr = pixd->loadXML(bstrLoad, &vbSuccess);
if (S_FALSE == hr)
{
hr = HRESULT_FROM_WIN32(ERROR_OPEN_FAILED);
}
if (FAILED(hr) && S_OK == pixd->get_parseError(&pixpe))
{
XmlReportParseError(pixpe);
}
ExitOnFailure(hr, "failed loadXML");
hr = S_OK;
LExit:
if (ppixdDocument)
{
*ppixdDocument = pixd;
pixd = NULL;
}
ReleaseBSTR(bstrLoad);
ReleaseObject(pixd);
ReleaseObject(pixpe);
return hr;
}