谁知道msxml中的insertBefore怎么用,紧急求助

elux 2003-09-23 03:44:44
C/C++ Syntax
HRESULT insertBefore(
IXMLDOMNode *newChild,
VARIANT refChild,
IXMLDOMNode **outNewChild);
给个例子
以前的帖子好像不行尤其是第二个参数
...全文
107 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
不用麻烦大家了,是智能指针惹的祸
:)
  • 打赏
  • 举报
回复
MSXML2::IXMLDOMNodePtr pTestNode;
pDoc->raw_selectSingleNode((_bstr_t)"/开目信息文件/数据/元素", &pTestNode);
CComVariant vFirstChild = pTestNode;
Node->raw_insertBefore(newNode,vFirstChild,&pTestNode);

为什么vFirstChild的值为true,VT_BOOL
elux 2003-09-25
  • 打赏
  • 举报
回复
Thanks
ray428 2003-09-24
  • 打赏
  • 举报
回复
本想说点什么的,现在看来不需要了。
elux 2003-09-24
  • 打赏
  • 举报
回复
非常感谢您的回答
your help is greatly appreicated
I will try your codes.
hope it works
saucer 2003-09-23
  • 打赏
  • 举报
回复
should be a node, from the documentation:

refChild
A variant. The address of the reference node; the newChild parameter is inserted to the left of the refChild parameter. If Null, the newChild parameter is inserted at the end of the child list.


examples:
IXMLDOMProcessingInstructionPtr pPI = NULL;

pPI = pXMLDoc->createProcessingInstruction
("xml", "version='1.0' encoding='UTF-8'");

_variant_t vNullVal;
vNullVal.vt = VT_NULL;
pXMLDoc->insertBefore(pPI, vNullVal);

or

CComVariant varType = NODE_ELEMENT;
pDoc->createNode(varType, bstrName, NULL, &pNewNode); //
CComPtr<IXMLDOMNode> pNewNode;
CComVariant varNode = pNode; // pNode is the existing node in the
document
pEle->insertBefore(pNewNode, varNode, &pReturnNode); // insert the
node.


or

CComVariant vFirstChild( pFirstChild );
hResult = m_spDOM->insertBefore( pInstruction, vFirstChild, &pNewChild );


3,055

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC HTML/XML
社区管理员
  • HTML/XML社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧