Rumah > Soal Jawab > teks badan
我使用VS2015/VC++来建立一个XML文件,首先引入了msxml6, 然后参考了微软的示例代码如下:
import "msxml6.dll"
using namespace MSXML2;
主循环里的代码如下:
MSXML2::IXMLDOMDocumentPtr pXMLDom;
HRESULT hr = pXMLDom.CreateInstance(__uuidof(MSXML2::DOMDocument60), NULL, CLSCTX_INPROC_SERVER);
if (FAILED(hr))
{
printf("Failed to instantiate an XML DOM.\n");
return;
}
try
{
pXMLDom->async = VARIANT_FALSE;
pXMLDom->validateOnParse = VARIANT_FALSE;
pXMLDom->resolveExternals = VARIANT_FALSE;
pXMLDom->preserveWhiteSpace = VARIANT_TRUE;
// Create a processing instruction targeted for xml.
MSXML2::IXMLDOMProcessingInstructionPtr pi = pXMLDom->createProcessingInstruction(L"xml", L"version='1.0'");
**pXMLDom->appendChild(pi);**
// Create a comment for the document.
MSXML2::IXMLDOMCommentPtr pc = pXMLDom->createComment(L"sample xml file created using XML DOM object.");
**pXMLDom->appendChild(pc);**
...... }
但是VS2015总是报class "MSXML2::IXMLDOMDocument" 没有成员 "appendChild". 编译是也是报错,网上查夜查不到答案。有没有人知道为什么?