国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

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

瀏覽:163日期: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".
復制代碼 代碼如下:
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var rootElement=xmlDoc.createElement("memo");
rootElement.setAttribute("author", "Pat Coleman");
xmlDoc.appendChild(rootElement);


VBScript
復制代碼 代碼如下:
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".

復制代碼 代碼如下:
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
復制代碼 代碼如下:
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
相關文章:
主站蜘蛛池模板: 久久久精品一区 | 亚洲经典在线观看 | 99精品久久久久久久免费看蜜月 | 一级特黄性色生活片一区二区 | 欧美色网在线 | 日本精品夜色视频一区二区 | 成人免费观看永久24小时 | 国产精品手机视频一区二区 | 喷潮白浆 | 在线免费观看欧美 | 欧美国产精品亚洲精品第一区 | 国产v日韩v欧美v精品专区 | 草草日| 色婷婷激婷婷深爱五月老司机 | 免费国产成人午夜在线观看 | 成年女人免费看 | 精品久久久视频 | 美国黑人特大一级毛片 | 亚洲一区二区三区不卡在线播放 | 97青娱国产盛宴精品视频 | 国产亚洲欧美日韩在线观看一区二区 | 欧美成在线视频 | 亚洲午夜久久久久影院 | 日韩成人精品日本亚洲 | 国内偷拍免费视频 | 99精品国产在现线免费 | 国产成人咱精品视频免费网站 | 午夜宅男在线永久免费观看网 | 久久极品| 中文字幕亚洲视频 | 香蕉成人在线视频 | 欧美日韩一区二区三区视视频 | 精品日韩一区二区三区 | 日韩免费高清一级毛片在线 | 加勒比一本大道香蕉在线视频 | 亚洲精品aaa| 萌白酱国产一区 | 国产精品国产三级国产专 | 亚洲性视频在线 | 日韩国产在线 | 日本成人中文字幕 |