色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

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

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

瀏覽:200日期: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
相關文章:
主站蜘蛛池模板: 日本在线观看免费视频网址 | 国产看午夜精品理论片 | 免费人成在线观看播放国产 | 亚洲三级中文字幕 | 最新三级网站 | 色屁屁一区二区三区视频国产 | 亚洲区精品久久一区二区三区 | 亚洲国产精品综合久久久 | 日韩毛片基地 | 久久精品视频3 | 一级毛片免费观看 | 成人精品视频在线观看播放 | 伊在人香蕉99久久 | 久久综合给会久久狠狠狠 | 日本一级毛片片在线播放 | 青青草原色 | 久久精品人人爽人人爽快 | 毛片免费高清免费 | 深夜国产成人福利在线观看女同 | 成人18免费入口 | 久久精品男人的天堂 | 正能量www正能量免费网站 | 欧美另类69xxxxx极品 | 男女性男女刺激大片免费观看 | 午夜剧场福利社 | 欧美第一视频 | 日韩黄色一级片 | 国产成人精品综合网站 | xxxwww在线播放 | 毛片视频免费观看 | 亚洲毛片免费视频 | 成人永久福利在线观看不卡 | 日本欧美不卡一区二区三区在线 | 国产第一页在线观看 | 久久精品免费观看视频 | 欧美亚洲日本一区二区三区浪人 | 男女很舒服爽视频免费 | 亚洲精品不卡午夜精品 | 免费欧美一级 | 国产三级日本三级在线播放 | 久久精品道一区二区三区 |