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

首頁 > 開發(fā) > XML > 正文

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

2024-09-05 20:53:45
字體:
供稿:網(wǎng)友
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)
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 午夜a狂野欧美一区二区 | 成人男女激情免费视频 | 91看片在线观看视频 | 久久久久亚洲视频 | videos韩国 | 玩偶姐姐在线观看免费 | 逼片| 毛片午夜 | 国产精品久久久久久久久久久天堂 | 国产91av视频 | 国产精品午夜未成人免费观看 | 国产一精品一av一免费爽爽 | 美女福利视频国产 | 欧美日韩手机在线观看 | 久久777国产线看观看精品 | 国产视频在线观看一区二区三区 | 国产一国产精品一级毛片 | 高清中文字幕在线 | 一级免费a | 欧美日韩免费看 | 中文字幕精品在线播放 | 青青草免费观看 | h网站在线观看 | 毛片免费看网站 | 欧美成人一区免费视频 | 黄色免费在线网站 | 亚洲91精品 | 国产九色在线播放九色 | www.69色| 视频一区二区三区中文字幕 | 中国久久久 | 性猛aa久久久 | 亚洲精品一区二区三区免 | 久久艹艹艹 | 欧美性受xxxx人人本视频 | 黄色的视频免费看 | 超碰97最新 | 久久精品美乳 | 国产乱一区二区三区视频 | 久久久国产电影 | 黄色特级视频 |