Discussion:
example compile error and a solution
(too old to reply)
s***@inbox.ru
2006-12-20 07:17:10 UTC
Permalink
Hi, Everyone!

I wish to post a solution to a problem listed in another 3 years old
topic, wich hasn't yet been described and thus is not available for
those who still faces it.

The error was:

===================================================================
I am getting a "C2039: 'attributes' : is not a member
of 'IXMLDOMNode'
c:\relcalc\relcalc\debug\msxml4.tlh(332) : see
declaration of 'IXMLDOMNode' " compile time error when I
try to call the function in the following code:

#import <msxml4.dll> raw_interfaces_only
using namespace MSXML2;

int NIModule::createXMLFile(char * inputArr[])
{
IXMLDOMDocument *pXMLDom=NULL;
IXMLDOMNode *pRoot=NULL;
IXMLDOMAttribute *pa=NULL;
VARIANT var;
BSTR bstr = NULL;
BSTR bstr1 = NULL;

// Create the root element.
bstr = SysAllocString(L"ns1:netInventory");
bstr1 = SysAllocString(L"http://netml");
pXMLDom->createNode(var, bstr, bstr1, &pRoot);
SysFreeString(bstr);
bstr = NULL;
SysFreeString(bstr1);
bstr1 = NULL;

// Create a "xsi:schemaLocation" attribute
bstr = SysAllocString(L"schemaLocation");
var = VariantString(L"http://");
pXMLDom->createAttribute(bstr,&pa);
pa->put_value(var);
pRoot->attributes->setNamedItem(pa);

}

===================================================================


So the solution is to delete "using namespace MSXML2;" and to use
"MSXML2::"-prefix instead.

Best regards,
Jure
Umut Alev [MSFT]
2006-12-28 06:39:31 UTC
Permalink
Antoher thing that you can do is use "include <msxml2.h>" instead of "import
<...>...."

By the way your solution here AVs as pXMLDOM is null when you call
createNode.

Cheers and Happy New Year,
- Umut Alev [MSFT]
Post by s***@inbox.ru
Hi, Everyone!
I wish to post a solution to a problem listed in another 3 years old
topic, wich hasn't yet been described and thus is not available for
those who still faces it.
===================================================================
I am getting a "C2039: 'attributes' : is not a member
of 'IXMLDOMNode'
c:\relcalc\relcalc\debug\msxml4.tlh(332) : see
declaration of 'IXMLDOMNode' " compile time error when I
#import <msxml4.dll> raw_interfaces_only
using namespace MSXML2;
int NIModule::createXMLFile(char * inputArr[])
{
IXMLDOMDocument *pXMLDom=NULL;
IXMLDOMNode *pRoot=NULL;
IXMLDOMAttribute *pa=NULL;
VARIANT var;
BSTR bstr = NULL;
BSTR bstr1 = NULL;
// Create the root element.
bstr = SysAllocString(L"ns1:netInventory");
bstr1 = SysAllocString(L"http://netml");
pXMLDom->createNode(var, bstr, bstr1, &pRoot);
SysFreeString(bstr);
bstr = NULL;
SysFreeString(bstr1);
bstr1 = NULL;
// Create a "xsi:schemaLocation" attribute
bstr = SysAllocString(L"schemaLocation");
var = VariantString(L"http://");
pXMLDom->createAttribute(bstr,&pa);
pa->put_value(var);
pRoot->attributes->setNamedItem(pa);
}
===================================================================
So the solution is to delete "using namespace MSXML2;" and to use
"MSXML2::"-prefix instead.
Best regards,
Jure
Continue reading on narkive:
Loading...