#import "msxml6.dll"
#include "MTVERIFY.h"
using namespace MSXML2;
//将某个节点导入到另一个文档中
void Test1()
{
MSXML2::IXMLDOMDocumentPtr doc;
HRESULT hr = doc.CreateInstance(__uuidof(MSXML2::DOMDocument60),0);
VARIANT_BOOL bRet = doc->load(_bstr_t(L"uu.xml"));
if ( bRet == VARIANT_FALSE )
{
wprintf( L"Load Faild %s %s\n", _com_error(hr).ErrorMessage(), CLastErr().Msg() ) ;
return ;
}
MSXML2::IXMLDOMNodePtr cnode = doc->GetdocumentElement()->selectSingleNode(_bstr_t(L"//User"));
MSXML2::IXMLDOMDocument3Ptr doc2;
hr = doc2.CreateInstance(__uuidof(MSXML2::DOMDocument60),0);
MSXML2::IXMLDOMNodePtr pNode = doc2->importNode( cnode,VARIANT_TRUE );
doc2->appendChild( pNode );
}
posted on 2009-05-23 11:03
鹿哥 阅读(351)
评论(0) 编辑 收藏 引用