#include "stdafx.h"
#include <objbase.h>
#include <iostream>
#import <msxml3.dll>
#include <atlcomcli.h>
using namespace MSXML2;int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);

MSXML2::IXMLDOMDocumentPtr docPtr;
docPtr.CreateInstance("Msxml2.DOMDocument.3.0"); char *xml = "<book><price>100</price></book>";
docPtr->loadXML(xml); MSXML2::IXMLDOMNodePtr firstChildNode = docPtr->documentElement->childNodes->item[0];
_bstr_t name(firstChildNode->nodeName); //验证这个firstChildNode的确是price MSXML2::IXMLDOMNodePtr newNode = docPtr->createNode(MSXML2::NODE_ELEMENT, "title", "");
docPtr->documentElement->insertBefore(newNode, _variant_t(firstChildNode));   //这里老崩溃 std::cout << docPtr->xml << std::endl; docPtr = NULL;
firstChildNode = NULL;
newNode = NULL; CoUninitialize();
system("pause");
return 0;
}如题, 真好msdn的insertbefore的c++版本又没有给出个例子,传不好了, 出了鬼了, 大家帮忙, 不胜感激啊.