insertBefore怎么用?

GEATA 2005-05-07 07:03:04
作 用
在指定的节点前插入一个子节点。  
基本语法
objDocumentNode = xmlDocumentNode.insertBefore(newChild,refChild);
 
说 明
newChild 是一个包含新子节点地址的对象,refChild 是参照节点的地址。新子节点被插到参照节点之前。如果refChild 参数没有包含在内,新的子节点会被插到子节点列表的末端。


================
这第二个参数到底时啥意思啊?
...全文
1102 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
GEATA 2005-05-12
  • 打赏
  • 举报
回复
非常感谢!
蒋晟 2005-05-11
  • 打赏
  • 举报
回复
用_variant_t的以IDispatch指针为参数的构造函数就可以了
GEATA 2005-05-11
  • 打赏
  • 举报
回复
能不能举个例子,比如说我现在有一个IXMLDOMNodePtr,怎样得到需要的类型?
蒋晟 2005-05-10
  • 打赏
  • 举报
回复
第二个参数应该传一个类型是VT_DISPATCH的变体
  • 打赏
  • 举报
回复
refChild [in]
The address of the reference node. The node specified is where the newChild node is to be inserted to the left as the preceding sibling in the child list. The node passed here must be a either a child node of the current node or Null. If the value is Null, the newChild node is inserted at the end of the child list. If the refChild node is not a child of the current node, an error is returned.


MSDN上写的 ??vc跟vb有什么不一样的??
GEATA 2005-05-09
  • 打赏
  • 举报
回复
不行啊,childNodes(0)返回的是node类型吧,
VC里面insertBefore ( struct IXMLDOMNode * newChild, const _variant_t & refChild )第二个参数可不是啊
jerry 2005-05-09
  • 打赏
  • 举报
回复
遇到Jiang Sir 只能 学习...... 了
  • 打赏
  • 举报
回复
又碰上jiangsheng了,呵呵
  • 打赏
  • 举报
回复
给你看我写的程序

public function additemblogm(blogtitle,blogcontent,thelink,thefile)
set addroot=thexmldom.createElement("blog")
set root=thexmldom.documentElement
set currnode = root.insertBefore(addroot, root.childNodes(0)) '注意这里,代表的是一个结点的位置,addroot是新建立的结点,建完了我们放哪呢,那就是root.childNodes(0)这个位置了
currnode.setAttribute "date",date
currnode.setAttribute "time",time
set blogtitleadd=thexmldom.createElement("blogtitle")
set blogtitled=currnode.appendchild(blogtitleadd)
blogtitled.text=blogtitle
set blogcontentadd=thexmldom.createElement("blogcontent")
set blogcontentd=currnode.appendchild(blogcontentadd)
blogcontentd.text=blogcontent
set bloglinkadd=thexmldom.createElement("link")
set bloglinkd=currnode.appendchild(bloglinkadd)
bloglinkd.text=thelink
set blogcommentadd=thexmldom.createElement("comment")
currnode.appendchild blogcommentadd
thexmldom.save thefile
end function
GEATA 2005-05-09
  • 打赏
  • 举报
回复
但是,这第二个参数到底该传些什么啊?
蒋晟 2005-05-08
  • 打赏
  • 举报
回复
使用appendChild添加的新的子节点会被插到子节点列表的末端。如果不想这么做,需要指定一个子节点作为参照,使用insertBefore或者insertAfter添加的新的子节点会被插到子节点列表中指定的节点之前或者之后。

3,056

社区成员

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

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