本文整理汇总了C++中IXMLDOMDocument::load方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMDocument::load方法的具体用法?C++ IXMLDOMDocument::load怎么用?C++ IXMLDOMDocument::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXMLDOMDocument
的用法示例。
在下文中一共展示了IXMLDOMDocument::load方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetIndent
/**
* XML 파일의 형태를 Tab을 이용해서 보기 좋게 정렬한다.
* \param szIndentFileName 정렬에 사용할 스타일 시트 파일명
* return 성공 유무
*/
bool CNtlXMLDoc::SetIndent(WCHAR* szIndentFileName)
{
IXMLDOMDocument* pXSL = NULL;
CoCreateInstance(__uuidof(DOMDocument30), NULL, CLSCTX_INPROC_SERVER, __uuidof(IXMLDOMDocument), (void**)&pXSL);
if(!pXSL)
return false;
VARIANT_BOOL vBool;
pXSL->put_async(VARIANT_FALSE);
pXSL->load((_variant_t)szIndentFileName, &vBool);
VARIANT vObject;
VariantInit(&vObject);
vObject.vt = VT_DISPATCH;
vObject.pdispVal = m_pXMLDocument;
m_pXMLDocument->transformNodeToObject(pXSL, vObject);
if(pXSL)
{
pXSL->Release();
pXSL = NULL;
}
return true;
}
示例2: 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;
}
示例3: insertDTIFileItem
int DicomImageSet::insertDTIFileItem(const QString &datasetFolderName, const QString &queryString, const QString &dtiFileName)
{
HRESULT hr = CoInitialize(NULL);
if (!SUCCEEDED(hr))
{
return 0;
}
QString datasetFileName = datasetFolderName+DATASET_FILE_NAME;
IXMLDOMDocument *pXMLDom = NULL;
IXMLDOMElement *pNode = NULL, *pParent = NULL;
BSTR bstrQuery = NULL;
VARIANT varFileName;
VARIANT_BOOL varStatus;
QString queryDTIFile;
CHK_HR(CreateAndInitDOM(&pXMLDom));
CHK_HR(VariantFromString(datasetFileName.toStdWString().c_str(), varFileName));
CHK_HR(pXMLDom->load(varFileName, &varStatus));
/*queryDTIFile = queryString+QString("/DTI[@file_name = '%1']").arg(dtiFileName);
bstrQuery = SysAllocString(queryString.toStdWString().c_str());
CHK_ALLOC(bstrQuery);
CHK_HR(pXMLDom->selectSingleNode(bstrQuery, (IXMLDOMNode**)&pNode));
SysFreeString(bstrQuery);
if (pNode)
{
return 1;
}*/
bstrQuery = SysAllocString(queryString.toStdWString().c_str());
CHK_ALLOC(bstrQuery);
CHK_HR(pXMLDom->selectSingleNode(bstrQuery, (IXMLDOMNode**)&pParent));
SysFreeString(bstrQuery);
if (pParent)
{
CHK_HR(CreateElement(pXMLDom, L"DTI", &pNode));
CHK_HR(CreateAndAddAttributeNode(pXMLDom, L"file_name", dtiFileName.toStdWString().c_str(), pNode));
CHK_HR(CreateAndAddTextNode(pXMLDom, L"\n", pParent));
CHK_HR(AppendChildToParent(pNode, pParent));
CHK_HR(pXMLDom->save(varFileName));
return 1;
}
CleanUp:
SAFE_RELEASE(pXMLDom);
SAFE_RELEASE(pNode);
return 0;
}
示例4: getOrderedDcmFiles
QStringList DicomImageSet::getOrderedDcmFiles(const QString &datasetFileName, const QString & queryString)
{
HRESULT hr = S_OK;
IXMLDOMDocument *pXMLDom = NULL;
IXMLDOMNodeList *pFileNodes = NULL;
VARIANT_BOOL varStatus;
VARIANT varFileName;
BSTR bstrQuery;
QStringList fileList;
CHK_HR(CreateAndInitDOM(&pXMLDom));
CHK_HR(VariantFromString(datasetFileName.toStdWString().c_str(), varFileName));
CHK_HR(pXMLDom->load(varFileName, &varStatus));
if (varStatus != VARIANT_TRUE)
{
CHK_HR(ReportParseError(pXMLDom, "Failed to load DOM from stocks.xml."));
}
bstrQuery = SysAllocString(queryString.toStdWString().c_str());
CHK_ALLOC(bstrQuery);
CHK_HR(pXMLDom->selectNodes(bstrQuery, &pFileNodes));
if (pFileNodes)
{
long nFiles;
CHK_HR(pFileNodes->get_length(&nFiles));
for (long i=0; i<nFiles; ++i)
{
VARIANT varValue;
IXMLDOMNode * pFile = NULL;
CHK_HR(pFileNodes->get_item(i, &pFile));
CHK_HR(GetAttributeFromNode(pFile, L"path", &varValue));
fileList <<QString::fromWCharArray(_bstr_t(varValue));
SAFE_RELEASE(pFile);
}
}
CleanUp:
SAFE_RELEASE(pXMLDom);
SAFE_RELEASE(pFileNodes);
return fileList;
}
示例5: XMLLoadFile
static IXMLDOMNode* XMLLoadFile(const TCHAR* pszFile)
{
HRESULT hr;
IXMLDOMElement* pRoot;
IXMLDOMDocument* pXMLDoc;
hr = CoCreateInstance(CLSID_DOMDocument,
NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument,
(void**)&pXMLDoc);
if(FAILED(hr))
return NULL;
_variant_t vSrc(pszFile);
VARIANT_BOOL vBool = VARIANT_FALSE;
hr = pXMLDoc->load(vSrc, &vBool);
if(FAILED(hr))
{
FC_RELEASE_PTR(pXMLDoc);
return NULL;
}
if(vBool!=VARIANT_TRUE)
{
FC_RELEASE_PTR(pXMLDoc);
return NULL;
}
pRoot = NULL;
hr = pXMLDoc->get_documentElement(&pRoot);
FC_RELEASE_PTR(pXMLDoc);
if(FAILED(hr) || !pRoot)
return NULL;
return pRoot;
}
示例6: getDTIFileName
QString DicomImageSet::getDTIFileName(const QString &datasetFolderName, const QString &queryString)
{
QString datasetFileName = datasetFolderName+DATASET_FILE_NAME;
HRESULT hr = S_OK;
IXMLDOMDocument *pXMLDom = NULL;
IXMLDOMNode *pFileNode = NULL;
VARIANT_BOOL varStatus;
VARIANT varFileName;
BSTR bstrQuery;
QStringList fileList;
CHK_HR(CreateAndInitDOM(&pXMLDom));
CHK_HR(VariantFromString(datasetFileName.toStdWString().c_str(), varFileName));
CHK_HR(pXMLDom->load(varFileName, &varStatus));
if (varStatus != VARIANT_TRUE)
{
CHK_HR(ReportParseError(pXMLDom, "Failed to load DOM from stocks.xml."));
}
bstrQuery = SysAllocString(QString(queryString+"/DTI").toStdWString().c_str());
CHK_ALLOC(bstrQuery);
CHK_HR(pXMLDom->selectSingleNode(bstrQuery, &pFileNode));
if (pFileNode)
{
VARIANT varValue;
CHK_HR(GetAttributeFromNode(pFileNode, L"file_name", &varValue));
return QString::fromWCharArray(_bstr_t(varValue));
}
CleanUp:
SAFE_RELEASE(pXMLDom);
SAFE_RELEASE(pFileNode);
return QString();
}
示例7: SetShadersGLSL
bool COpenGL::SetShadersGLSL(const TCHAR *glslFileName)
{
char *fragment=NULL, *vertex=NULL;
IXMLDOMDocument * pXMLDoc = NULL;
IXMLDOMElement * pXDE = NULL;
IXMLDOMNode * pXDN = NULL;
HRESULT hr;
BSTR queryString, nodeContent;
TCHAR errorMsg[MAX_PATH + 50];
if(fragmentShader) {
glDetachShader(shaderProgram,fragmentShader);
glDeleteShader(fragmentShader);
fragmentShader = 0;
}
if(vertexShader) {
glDetachShader(shaderProgram,vertexShader);
glDeleteShader(vertexShader);
vertexShader = 0;
}
if(shaderProgram) {
glUseProgram(0);
glDeleteProgram(shaderProgram);
shaderProgram = 0;
}
if(glslFileName==NULL || *glslFileName==TEXT('\0'))
return true;
if(!LoadShaderFunctions()) {
MessageBox(NULL, TEXT("Unable to load OpenGL shader functions"), TEXT("Shader Loading Error"),
MB_OK|MB_ICONEXCLAMATION);
return false;
}
hr = CoCreateInstance(CLSID_DOMDocument,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&pXMLDoc));
if(FAILED(hr)) {
MessageBox(NULL, TEXT("Error creating XML Parser"), TEXT("Shader Loading Error"),
MB_OK|MB_ICONEXCLAMATION);
return false;
}
VARIANT fileName;
VARIANT_BOOL ret;
fileName.vt = VT_BSTR;
#ifdef UNICODE
fileName.bstrVal = SysAllocString(glslFileName);
#else
wchar_t tempfilename[MAX_PATH];
MultiByteToWideChar(CP_UTF8,0,glslFileName,-1,tempfilename,MAX_PATH);
fileName.bstrVal = SysAllocString(tempfilename);
#endif
hr = pXMLDoc->load(fileName,&ret);
SysFreeString(fileName.bstrVal);
if(FAILED(hr) || hr==S_FALSE) {
_stprintf(errorMsg,TEXT("Error loading GLSL shader file:\n%s"),glslFileName);
MessageBox(NULL, errorMsg, TEXT("Shader Loading Error"), MB_OK|MB_ICONEXCLAMATION);
pXMLDoc->Release();
return false;
}
VARIANT attributeValue;
BSTR attributeName;
hr = pXMLDoc->get_documentElement(&pXDE);
if(FAILED(hr) || hr==S_FALSE) {
_stprintf(errorMsg,TEXT("Error loading root element from file:\n%s"),glslFileName);
MessageBox(NULL, errorMsg, TEXT("Shader Loading Error"), MB_OK|MB_ICONEXCLAMATION);
pXMLDoc->Release();
return false;
}
attributeName=SysAllocString(L"language");
pXDE->getAttribute(attributeName,&attributeValue);
SysFreeString(attributeName);
pXDE->Release();
if(attributeValue.vt!=VT_BSTR || lstrcmpiW(attributeValue.bstrVal,L"glsl")) {
_stprintf(errorMsg,TEXT("Shader language is <%s>, expected <GLSL> in file:\n%s"),attributeValue.bstrVal,glslFileName);
MessageBox(NULL, errorMsg, TEXT("Shader Loading Error"), MB_OK|MB_ICONEXCLAMATION);
if(attributeValue.vt==VT_BSTR) SysFreeString(attributeValue.bstrVal);
pXMLDoc->Release();
return false;
}
if(attributeValue.vt==VT_BSTR) SysFreeString(attributeValue.bstrVal);
queryString=SysAllocString(L"/shader/fragment");
hr = pXMLDoc->selectSingleNode(queryString,&pXDN);
SysFreeString(queryString);
if(hr == S_OK) {
hr = pXDN->get_text(&nodeContent);
if(hr == S_OK) {
int requiredChars = WideCharToMultiByte(CP_ACP,0,nodeContent,-1,fragment,0,NULL,NULL);
fragment = new char[requiredChars];
WideCharToMultiByte(CP_UTF8,0,nodeContent,-1,fragment,requiredChars,NULL,NULL);
}
//.........这里部分代码省略.........
示例8: FAILED
bool CDirect3D::SetShaderHLSL(const TCHAR *file)
{
//MUDLORD: the guts
//Compiles a shader from files on disc
//Sets LUT textures to texture files in PNG format.
TCHAR folder[MAX_PATH];
TCHAR rubyLUTfileName[MAX_PATH];
TCHAR *slash;
char *shaderText = NULL;
TCHAR errorMsg[MAX_PATH + 50];
IXMLDOMDocument * pXMLDoc = NULL;
IXMLDOMElement * pXDE = NULL;
IXMLDOMNode * pXDN = NULL;
BSTR queryString, nodeContent;
HRESULT hr;
shaderTimer = 1.0f;
shaderTimeStart = 0;
shaderTimeElapsed = 0;
if(effect) {
effect->Release();
effect = NULL;
}
for(int i = 0; i < MAX_SHADER_TEXTURES; i++) {
if (rubyLUT[i] != NULL) {
rubyLUT[i]->Release();
rubyLUT[i] = NULL;
}
}
if (file == NULL || *file==TEXT('\0'))
return true;
hr = CoCreateInstance(CLSID_DOMDocument,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&pXMLDoc));
if(FAILED(hr)) {
MessageBox(NULL, TEXT("Error creating XML Parser"), TEXT("Shader Loading Error"),
MB_OK|MB_ICONEXCLAMATION);
return false;
}
VARIANT fileName;
VARIANT_BOOL ret;
fileName.vt = VT_BSTR;
#ifdef UNICODE
fileName.bstrVal = SysAllocString(file);
#else
wchar_t tempfilename[MAX_PATH];
MultiByteToWideChar(CP_UTF8,0,file,-1,tempfilename,MAX_PATH);
fileName.bstrVal = SysAllocString(tempfilename);
#endif
hr = pXMLDoc->load(fileName,&ret);
SysFreeString(fileName.bstrVal);
if(FAILED(hr) || hr==S_FALSE) {
_stprintf(errorMsg,TEXT("Error loading HLSL shader file:\n%s"),file);
MessageBox(NULL, errorMsg, TEXT("Shader Loading Error"), MB_OK|MB_ICONEXCLAMATION);
pXMLDoc->Release();
return false;
}
VARIANT attributeValue;
BSTR attributeName;
hr = pXMLDoc->get_documentElement(&pXDE);
if(FAILED(hr) || hr==S_FALSE) {
_stprintf(errorMsg,TEXT("Error loading root element from file:\n%s"),file);
MessageBox(NULL, errorMsg, TEXT("Shader Loading Error"), MB_OK|MB_ICONEXCLAMATION);
pXMLDoc->Release();
return false;
}
attributeName=SysAllocString(L"language");
pXDE->getAttribute(attributeName,&attributeValue);
SysFreeString(attributeName);
pXDE->Release();
if(attributeValue.vt!=VT_BSTR || lstrcmpiW(attributeValue.bstrVal,L"hlsl")) {
_stprintf(errorMsg,TEXT("Shader language is <%s>, expected <HLSL> in file:\n%s"),attributeValue.bstrVal,file);
MessageBox(NULL, errorMsg, TEXT("Shader Loading Error"), MB_OK|MB_ICONEXCLAMATION);
if(attributeValue.vt==VT_BSTR) SysFreeString(attributeValue.bstrVal);
pXMLDoc->Release();
return false;
}
if(attributeValue.vt==VT_BSTR) SysFreeString(attributeValue.bstrVal);
queryString=SysAllocString(L"/shader/source");
hr = pXMLDoc->selectSingleNode(queryString,&pXDN);
SysFreeString(queryString);
if(hr == S_OK) {
hr = pXDN->get_text(&nodeContent);
if(hr == S_OK) {
int requiredChars = WideCharToMultiByte(CP_ACP,0,nodeContent,-1,shaderText,0,NULL,NULL);
shaderText = new char[requiredChars];
WideCharToMultiByte(CP_UTF8,0,nodeContent,-1,shaderText,requiredChars,NULL,NULL);
//.........这里部分代码省略.........
示例9: readDatasetFile
int DicomImageSet::readDatasetFile(const QString &datasetFileName, QTreeWidget *treeWidget)
{
HRESULT hr = S_OK;
IXMLDOMDocument *pXMLDom = NULL;
IXMLDOMNodeList *pPatients = NULL;
IXMLDOMNode *pPatient = NULL;
DOMNodeType nodeType;
VARIANT_BOOL varStatus;
VARIANT varFileName;
VARIANT varValue;
BSTR bstrQuery;
VariantInit(&varFileName);
VariantInit(&varValue);
QString queryPatient, queryDate, queryProtocol, queryCollection;
CHK_HR(CreateAndInitDOM(&pXMLDom));
CHK_HR(VariantFromString(datasetFileName.toStdWString().c_str(), varFileName));
CHK_HR(pXMLDom->load(varFileName, &varStatus));
if (varStatus != VARIANT_TRUE)
{
CHK_HR(ReportParseError(pXMLDom, "Failed to load DOM from stocks.xml."));
}
treeWidget->clear();
treeWidget->setColumnCount(1);
CHK_HR(pXMLDom->getElementsByTagName(L"Patient", &pPatients));
if (pPatients)
{
long nPatients;
CHK_HR(pPatients->get_length(&nPatients));
for (long i=0; i<nPatients; ++i)
{
CHK_HR(pPatients->get_item(i, &pPatient));
CHK_HR(GetAttributeFromNode(pPatient, L"patients_name", &varValue));
queryPatient = QString::fromWCharArray(_bstr_t(varValue));
QTreeWidgetItem * patientItem = new QTreeWidgetItem(treeWidget, QStringList(queryPatient));
patientItem->setExpanded(true);
IXMLDOMNodeList * pDates = NULL;
CHK_HR(pPatient->get_childNodes(&pDates));
long nDates;
CHK_HR(pDates->get_length(&nDates));
for (long j=0; j<nDates; ++j)
{
IXMLDOMNode * pDate = NULL;
CHK_HR(pDates->get_item(j, &pDate));
CHK_HR(pDate->get_nodeType(&nodeType));
if(nodeType!=NODE_ELEMENT)
{
continue;
}
CHK_HR(GetAttributeFromNode(pDate, L"acquisition_date", &varValue));
queryDate = QString::fromWCharArray(_bstr_t(varValue));
int intDate = queryDate.toInt();
QDate date = (QDate::fromString("1900-01-01", "yyyy-MM-dd")).addDays(intDate-693962);
QTreeWidgetItem * dateItem = new QTreeWidgetItem(patientItem, QStringList(date.toString("yyyy-MM-dd")));
dateItem->setExpanded(true);
IXMLDOMNodeList * pProtocols = NULL;
CHK_HR(pDate->get_childNodes(&pProtocols));
long nProtocols;
CHK_HR(pProtocols->get_length(&nProtocols));
for (long j=0; j<nProtocols; ++j)
{
IXMLDOMNode * pProtocol = NULL;
CHK_HR(pProtocols->get_item(j, &pProtocol));
CHK_HR(pProtocol->get_nodeType(&nodeType));
if(nodeType!=NODE_ELEMENT)
{
continue;
}
CHK_HR(GetAttributeFromNode(pProtocol, L"protocol_name", &varValue));
queryProtocol = QString::fromWCharArray(_bstr_t(varValue));
QTreeWidgetItem * protocolItem = new QTreeWidgetItem(dateItem, QStringList(queryProtocol));
protocolItem->setExpanded(true);
IXMLDOMNodeList * pCollections = NULL;
CHK_HR(pProtocol->get_childNodes(&pCollections));
long nCollections;
CHK_HR(pCollections->get_length(&nCollections));
for (long j=0; j<nCollections; ++j)
{
IXMLDOMNode * pCollection = NULL;
CHK_HR(pCollections->get_item(j, &pCollection));
CHK_HR(pCollection->get_nodeType(&nodeType));
if(nodeType!=NODE_ELEMENT)
{
continue;
}
CHK_HR(GetAttributeFromNode(pCollection, L"acquisition_number", &varValue));
queryCollection = QString::fromWCharArray(_bstr_t(varValue));
QTreeWidgetItem * collectionItem = new QTreeWidgetItem(protocolItem);
QString queryStr = QString("root/Patient[@patients_name = '%1']/Date[@acquisition_date = '%2']/Protocol[@protocol_name = '%3']/Collection[@acquisition_number = '%4']")
.arg(queryPatient).arg(queryDate).arg(queryProtocol).arg(queryCollection);
IXMLDOMElement * pDtiNode = NULL;
bstrQuery = SysAllocString(QString(queryStr+"/DTI").toStdWString().c_str());
//.........这里部分代码省略.........
示例10: queryNodes
void queryNodes()
{
HRESULT hr = S_OK;
IXMLDOMDocument *pXMLDom = NULL;
IXMLDOMNodeList *pNodes = NULL;
IXMLDOMNode *pNode = NULL;
BSTR bstrQuery1 = NULL;
BSTR bstrQuery2 = NULL;
BSTR bstrNodeName = NULL;
BSTR bstrNodeValue = NULL;
VARIANT_BOOL varStatus;
VARIANT varFileName;
VariantInit(&varFileName);
CHK_HR(CreateAndInitDOM(&pXMLDom));
CHK_HR(VariantFromString(L"stocks.xml", varFileName));
CHK_HR(pXMLDom->load(varFileName, &varStatus));
if (varStatus != VARIANT_TRUE)
{
CHK_HR(ReportParseError(pXMLDom, "Failed to load DOM from stocks.xml."));
}
// Query a single node.
bstrQuery1 = SysAllocString(L"//stock[1]/*");
CHK_ALLOC(bstrQuery1);
CHK_HR(pXMLDom->selectSingleNode(bstrQuery1, &pNode));
if (pNode)
{
printf("Result from selectSingleNode:\n");
CHK_HR(pNode->get_nodeName(&bstrNodeName));
printf("Node, <%S>:\n", bstrNodeName);
SysFreeString(bstrNodeName);
CHK_HR(pNode->get_xml(&bstrNodeValue));
printf("\t%S\n\n", bstrNodeValue);
SysFreeString(bstrNodeValue);
SAFE_RELEASE(pNode);
}
else
{
CHK_HR(ReportParseError(pXMLDom, "Error while calling selectSingleNode."));
}
// Query a node-set.
bstrQuery2 = SysAllocString(L"//stock[1]/*");
CHK_ALLOC(bstrQuery2);
CHK_HR(pXMLDom->selectNodes(bstrQuery2, &pNodes));
if(pNodes)
{
printf("Results from selectNodes:\n");
//get the length of node-set
long length;
CHK_HR(pNodes->get_length(&length));
for (long i = 0; i < length; i++)
{
CHK_HR(pNodes->get_item(i, &pNode));
CHK_HR(pNode->get_nodeName(&bstrNodeName));
/*if(0== wcscmp(bstrNodeValue, L"symbol"))
{
}
*/
printf("Node (%d), <%S>:\n", i, bstrNodeName);
SysFreeString(bstrNodeName);
CHK_HR(pNode->get_xml(&bstrNodeValue));
printf("\t%S\n", bstrNodeValue);
SysFreeString(bstrNodeValue);
SAFE_RELEASE(pNode);
}
}
else
{
CHK_HR(ReportParseError(pXMLDom, "Error while calling selectNodes."));
}
CleanUp:
SAFE_RELEASE(pXMLDom);
SAFE_RELEASE(pNodes);
SAFE_RELEASE(pNode);
SysFreeString(bstrQuery1);
SysFreeString(bstrQuery2);
SysFreeString(bstrNodeName);
SysFreeString(bstrNodeValue);
VariantClear(&varFileName);
}
示例11: 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;
}