Applies to: IXMLDOMElementsetAttribute Method [Visual Basic]
Sets the value of the named attribute.[Script]
Script Syntax
oXMLDOMElement.setAttribute(name, value);
Parameters
name
The string specifying the name of the attribute. If the attribute with that name already exists, its value is changed. If the attribute with that name does not exist, it is created.
value
The variant that supplies the value for the named attribute.
Example
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
var nodeBook;
xmlDoc.async = false;
xmlDoc.load("books.xml");
nodeBook = xmlDoc.selectSingleNode("//book");
nodeBook.setAttribute("PublishDate", String(Date()))
alert(nodeBook.getAttribute("PublishDate"));
[Visual Basic]
Visual Basic Syntax
oXMLDOMElement.setAttribute(name, value)
Parameters
name
The string specifying the name of the attribute. If the attribute with that name already exists, its value is changed. If the attribute with that name does not exist, it is created.
value
The variant that supplies the value for the named attribute.
Example
Dim xmlDoc As New Msxml2.DOMDocument40
Dim nodeBook As IXMLDOMElement
xmlDoc.async = False
xmlDoc.Load "books.xml"
Set nodeBook = xmlDoc.selectSingleNode("//book")
nodeBook.setAttribute "PublishDate", Now
MsgBox nodeBook.getAttribute("PublishDate")
Sets the value of the named attribute.[Script]
Script Syntax
oXMLDOMElement.setAttribute(name, value);
Parameters
name
The string specifying the name of the attribute. If the attribute with that name already exists, its value is changed. If the attribute with that name does not exist, it is created.
value
The variant that supplies the value for the named attribute.
Example
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
var nodeBook;
xmlDoc.async = false;
xmlDoc.load("books.xml");
nodeBook = xmlDoc.selectSingleNode("//book");
nodeBook.setAttribute("PublishDate", String(Date()))
alert(nodeBook.getAttribute("PublishDate"));
[Visual Basic]
Visual Basic Syntax
oXMLDOMElement.setAttribute(name, value)
Parameters
name
The string specifying the name of the attribute. If the attribute with that name already exists, its value is changed. If the attribute with that name does not exist, it is created.
value
The variant that supplies the value for the named attribute.
Example
Dim xmlDoc As New Msxml2.DOMDocument40
Dim nodeBook As IXMLDOMElement
xmlDoc.async = False
xmlDoc.Load "books.xml"
Set nodeBook = xmlDoc.selectSingleNode("//book")
nodeBook.setAttribute "PublishDate", Now
MsgBox nodeBook.getAttribute("PublishDate")
解决方案 »
- 请问用VB能不能实现这样的功能:获取另一个程序正在运行的窗口上控件的一些属性值
- SQL- select m1&m2&m3 from table二次查询问题
- VB如何实现CMD命令的映射磁盘?
- 采用了winsock控件,协议是udp,该如何实现广播功能呢?
- 跪求VB扫雷游戏算法思想
- 请问:如何将2个byte 转换成1个int, 需要区分正负号。
- 我坚持VB的10大理由,和3大受益,大家还有补充的吗?
- VB 如何模拟鼠标按下左键后左右移动鼠标?
- vb中的报表怎么多列打印?
- 怎样用VB程序读写ini文件?
- vb + sqlserver 做一个程序。运行程序时,sql server要先启动。而vb + access做一个程序。确不需要access启动?
- 关于让窗口显示在最前端的问题,谢谢您告诉我!
Dim Docxml As DOMDocument
Dim objxmlelm As IXMLDOMElement Set Docxml = New DOMDocument
Docxml.async = False
Docxml.Load ("D:\modi.xml")
Set objxmlelm = Docxml.selectSingleNode("//modi_date")
Call objxmlelm.setAttribute("modi_date", Now)End Sub这样还是不行,请给找错误