I'm using vs2015/vc++ to generate a XML document.I follow a example from Microsoft document. First of all, I add this:
import "msxml6.dll"
using namespace MSXML2;*
Then in the main loop I add such codes:
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);
...... }
But the VS2015 always told me that class "MSXML2::IXMLDOMDocument" has no member "appendChild". Also I could not compile it. I google a lot but could not find the answer. Does anyone know the reason? Thank you.
You can try something like this
I had the same problem and worked for me