久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

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

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

瀏覽:204日期: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)
標(biāo)簽: XML/RSS
相關(guān)文章:
主站蜘蛛池模板: 巴西性猛交xxxx免费看久久久 | 久久久久久日产精品 | 亚洲精品视频区 | 免费中文字幕日韩欧美 | 欧美日一区二区 | 久久久精彩视频 | 国产a免费| 亚洲一区精品视频 | 成人做爰69片免费 | t66y最新地址一地址二69 | 久久综合av | 午夜在线观看免费 | 毛片网站在线观看 | 欧美精品一二三区 | 国产一区二区三区久久久久久久久 | 中文字幕视频在线免费观看 | 天天干天天操天天干 | 亚欧毛片 | 99精品欧美一区二区蜜桃免费 | 在线观看三级av | 国产精品久久久久久久午夜 | 老司机精品福利视频 | 2021最新热播中文字幕-第1页-看片视频 青青青久草 | 国产精品一二三四区 | 亚洲啊v在线 | 欧美激情在线狂野欧美精品 | 在线看一区二区 | 国产aⅴ一区二区 | 国产精品91网站 | av在线播放网址 | 久久天堂av综合合色蜜桃网 | 久久精品视频免费观看 | 国内精品99 | 超碰伊人网 | 一级色网站 | 免费色在线| 精品第一页| 国产高清视频在线 | 日韩中文字幕一区二区高清99 | 亚洲第一性理论片 | 搡女人真爽免费午夜网站 |