在头上引用:
#import "msxml4.dll" named_guids
using namespace MSXML2;
CoInitialize(NULL);
MSXML2::IXMLDOMDocumentPtr pCommandDoc;
pCommandDoc.CreateInstance(__uuidof(MSXML2::DOMDocument));
BOOL bLoad = pCommandDoc->load(L"chenxiaoqin1234258416128.xml");
if (bLoad)
::MessageBox(NULL, pCommandDoc->xml,"XML",MB_OK);
else
::MessageBox(NULL, "Failed to load the XML file","XML",MB_OK);
CString strTemp;
IXMLDOMNodeListPtr nodeList;
IXMLDOMNodePtr objNode;
MSXML2::IXMLDOMNamedNodeMapPtr pAttrs;
IXMLDOMNodePtr objNode1;
nodeList = pCommandDoc->documentElement->childNodes;
for (int i=0; ilength;++i)
{
objNode = nodeList->nextNode();
::MessageBox(NULL,objNode->text,"key Node",MB_OK);
objNode->get_attributes(&pAttrs);
if (pAttrs ==NULL)
return;
MSXML2::IXMLDOMNodePtr pRequestTypeAttr=pAttrs->getQualifiedItem("Date","");
if (pRequestTypeAttr !=NULL)
//continue;
{
_bstr_t strRequestType=pRequestTypeAttr->Gettext();
strTemp=strRequestType.operator char *();
::MessageBox(NULL,strTemp,"key Node",MB_OK);
}
MSXML2::IXMLDOMNodePtr prnode = pAttrs->getQualifiedItem("Time","");
if (prnode!=NULL)
{
_bstr_t strtype = prnode->Gettext();
strTemp=strtype.operator char *();
::MessageBox(NULL,strTemp,"key Node",MB_OK);
}
//MSXML2::IXMLDOMNodePtr pRootNode = objNode->selectSingleNode("From/User");
MSXML2::IXMLDOMNodePtr pRootNode=pCommandDoc->selectSingleNode("Log/Message/From/User");
if (pRootNode==NULL)
{
continue ;
}
CString strTemp1;
MSXML2::IXMLDOMNamedNodeMapPtr pAttrs1 = NULL;
pRootNode->get_attributes(&pAttrs1);
if (pAttrs==NULL)
{
continue;
}
MSXML2::IXMLDOMNodePtr pRequestTypeAttr11=pAttrs1->getQualifiedItem("FriendlyName","");
_bstr_t strRequestType2=pRequestTypeAttr11->Gettext();
strTemp1=strRequestType2.operator char *();
::MessageBox(NULL,strTemp1,"key Node",MB_OK);
MSXML2::IXMLDOMNodePtr pRootNode3=pCommandDoc->selectSingleNode("Log/Message/To/User");
if (pRootNode3==NULL)
{
continue ;
}
CString strTemp3;
MSXML2::IXMLDOMNamedNodeMapPtr pAttrs3 = NULL;
pRootNode3->get_attributes(&pAttrs3);
if (pAttrs3==NULL)
{
continue;
}
MSXML2::IXMLDOMNodePtr pRequestTypeAttr113=pAttrs3->getQualifiedItem("FriendlyName","");
_bstr_t strRequestType3=pRequestTypeAttr113->Gettext();
strTemp3=strRequestType3.operator char *();
::MessageBox(NULL,strTemp3,"key Node",MB_OK);
}
CoUninitialize();
阅读(1809) | 评论(1) | 转发(0) |