1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| CString GetUrl(CString stServeur){
IXMLDOMDocumentPtr m_plDomDocument;
IXMLDOMElementPtr m_pDomElement;
IXMLDOMNodePtr m_pDomNode;
IXMLDOMNodeListPtr m_pDomNodeList;
CString stCourant, stFinal;
// Initialize COM
::CoInitialize(NULL);
HRESULT hr = m_plDomDocument.CreateInstance(CLSID_DOMDocument60);
if (FAILED(hr)) {
_com_error er(hr);
AfxMessageBox(er.ErrorMessage());
}
// specify xml file name
CString strFileName (stServeur + CST_CHEMIN_FICHIER_XML_CONF);
AfxMessageBox("Filename " + strFileName);
// convert xml file name string to something COM can handle (BSTR)
_bstr_t bstrFileName;
bstrFileName = strFileName.AllocSysString();
// call the IXMLDOMDocumentPtr's load function to load the XML document
VARIANT_BOOL vResult;
vResult = m_plDomDocument->load(bstrFileName);
if (vResult == FALSE) {
AfxMessageBox("GetUrl::XML Document FAILED to load!");
}
/* Traitement sur le fichier */
} |
Partager