insertBefore

wxdqz

New Member
Have anyone ever use insertBefore function from MSXML3 in your C++ program?If yes, can you share how you do that?I am trying to use this function as below:IXMLDOMNodePtr pETNode = pSchemaDoc->createNode((long)NODE_ELEMENT, _T("ElementType"),"");ASSERT(NULL != pETNode);pParentNode->insertBefore(pETNode, _variant_t(pParentNode->firstChild));//pParentNode->insertBefore(pETNode, _variant_t((short)NULL)); <-- failed//pParentNode->appendChild(pETNode); <-- worksIt gave me an exception and say "The parameter is incorrect". Does anyonehave any idea why it happened? The type of pSchemaDoc is IXMLDOMDocument2Ptr,and the type of pParentNode is IXMLDOMNodePtr whose nodeType is NODE_ELEMENT.It gave me the same exception if I passed in NULL as the second parameter.According to the documentation, it should be the same as using appendChild.It works fine if I use appendChild().I want to add the node to the beginning of the tree.Thanks.Elaine
 
Back
Top