麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 開發 > XML > 正文

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

2024-09-05 20:55:01
字體:
來源:轉載
供稿:網友
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".
復制代碼 代碼如下:www.companysz.com

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var rootElement=xmlDoc.createElement("memo");
rootElement.setAttribute("author", "Pat Coleman");
xmlDoc.appendChild(rootElement);


VBScript
復制代碼 代碼如下:www.companysz.com

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".

復制代碼 代碼如下:www.companysz.com

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
復制代碼 代碼如下:www.companysz.com

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)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 曰韩黄色片 | 日韩中字在线 | av日韩在线免费观看 | 久久免费视频5 | 91av在线影院 | 国产高潮国产高潮久久久91 | 精品一区二区三区在线观看视频 | 精品人伦一区二区三区蜜桃网站 | 免费日本一区二区 | 露脸各种姿势啪啪的清纯美女 | 午夜久久视频 | 美女色影院 | 精品久久久一 | 一色桃子av大全在线播放 | 亚洲一区二区三区四区精品 | 草莓福利社区在线 | 欧美日韩亚洲在线 | 99精美视频 | 久久久久国产成人免费精品免费 | 欧洲色阁中文字幕 | 亚洲电影在线播放 | 91短视频在线 | 欧美成人性色 | 色播视频网站 | 国产美女白浆 | 草草在线视频 | 激情小说激情图片激情电影 | 久国产| 中文字幕欧美一区二区三区 | wwwxxx国产 | 久久亚洲国产精品 | 成人毛片100部| 日本综合久久 | 欧洲狠狠鲁 | 欧美特黄一级高清免费的香蕉 | 春光影院理论片 | 亚洲国产精品久久久久久久久久 | 国产一区二区在线免费播放 | 久久精品久久精品久久精品 | 久久999精品久久久 国产噜噜噜噜久久久久久久久 | 被啪羞羞视频在线观看 |