av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

jscript與vbscript 操作XML元素屬性的代碼

瀏覽:217日期:2022-06-04 11:41:41
Although attributes belong to a particular element, they are not considered child nodes of element nodes. Instead, they behave more like properties of IXMLDOMElement.

Most of the methods for working with attributes come from IXMLDOMElement. Attributes can be manipulated in the following ways.

Directly, through the getAttribute and setAttribute methods of IXMLDOMElement.

As named IXMLDOMAttribute nodes, with getAttributeNode and setAttributeNode.

As a set of nodes accessible through the attributes property and returned as an IXMLNamedNodeMap.

Examples
JScript
The following JScript example creates a new document containing a <memo> element, and then creates an attribute named author with a value of "Pat Coleman".
復(fù)制代碼 代碼如下:
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var rootElement=xmlDoc.createElement("memo");
rootElement.setAttribute("author", "Pat Coleman");
xmlDoc.appendChild(rootElement);


VBScript
復(fù)制代碼 代碼如下:
Set xmlDoc = CreateObject("Msxml2.DOMDocument.3.0")
Set rootElement=xmlDoc.createElement("memo")
rootElement.setAttribute("author", "Pat Coleman")
xmlDoc.appendChild(rootElement)


If you prefer to work with attribute nodes, you can create the attribute, and then create a text node to store its value. Attribute nodes can only contain text nodes and entity reference nodes. (If you need to create an attribute containing an entity reference, you must use this approach.)

Working with attribute nodes requires using the DOMDocument object to create attribute and text (and entity reference, if necessary) nodes before assigning the nodes to the element.

JScript
The following JScript code uses this approach to perform the same work as the preceding examples, creating a <memo> element with an author attribute holding the value "Pat Coleman".

復(fù)制代碼 代碼如下:
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var rootElement=xmlDoc.createElement("memo");
var memoAttribute=xmlDoc.createAttribute("author");
var memoAttributeText=xmlDoc.createTextNode("Pat Coleman");
memoAttribute.appendChild(memoAttributeText);
rootElement.setAttributeNode(memoAttribute);
xmlDoc.appendChild(rootElement);


VBScript
復(fù)制代碼 代碼如下:
Set xmlDoc = CreateObject("Msxml2.DOMDocument.3.0")
Set rootElement=xmlDoc.createElement("memo")
Set memoAttribute=xmlDoc.createAttribute("author")
Set memoAttributeText=xmlDoc.createTextNode("Pat Coleman")
memoAttribute.appendChild(memoAttributeText)
rootElement.setAttributeNode(memoAttribute)
xmlDoc.appendChild(rootElement)
標簽: XML/RSS
相關(guān)文章:
主站蜘蛛池模板: 中文一级片 | 日本一区视频在线观看 | 先锋资源吧 | 一区二区三区中文 | 国产在线拍偷自揄拍视频 | 中文字幕黄色大片 | 91精品在线播放 | 中文字幕一区二区三区四区五区 | 一级黄色片毛片 | 国产丝袜av | 久草视| 日本高清视频在线播放 | 日韩2020狼一二三 | 99久久久国产精品 | 欧美视频一级 | 亚洲欧美日韩电影 | 日韩欧美在线免费观看 | 天天操夜夜操 | 国产成都精品91一区二区三 | 成人免费视频网站在线看 | 在线观看视频中文字幕 | 久久久久久久久久久久91 | 国产日产精品一区二区三区四区 | h免费观看 | 国产精品污www一区二区三区 | 视频在线一区 | 岛国毛片在线观看 | 亚洲欧美一区二区三区在线 | 日韩精品一区二区三区视频播放 | 国产一级片在线观看视频 | 男人天堂视频在线观看 | 国产综合在线视频 | 日韩欧美理论片 | 日韩三级电影一区二区 | 日韩在线不卡视频 | 99爱在线免费观看 | 色欧美片视频在线观看 | 亚州综合一区 | 日韩免费视频 | 欧美激情一区二区 | 久久小视频 |