亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

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

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

瀏覽:169日期: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
相關(guān)文章:
主站蜘蛛池模板: 九九精品视频在线免费观看 | 国产麻豆视频在线看网站 | 成人精品视频在线观看播放 | 国产主播福利一区二区 | 五月天婷婷网站 | 欧美日本亚洲国产一区二区 | 黄色成人一级片 | 免费观看一级黄色片 | 久99久精品视频免费观看v | 国产欧美二区 | 182tv成人午夜在线观看 | 小泽玛利亚在线精品一区二区 | 欧美成人精品一区二三区在线观看 | 蕾丝视频在线看片国产 | 性亚洲精品 | 日韩永久免费视频 | 国产最新地址 | 一区二区三区四区在线视频 | 亚洲免费人成在线视频观看 | 久久精品免费全国观看国产 | 日本在线观看免费看片 | 亚洲热热久久九九精品 | 亚洲欧美日韩高清在线看 | 成人国产精品一级毛片了 | 国产精品欧美视频另类专区 | 在线看黄色 | 在线观看国产精品一区 | 深夜爽爽爽gif福利免费 | 欧美成人免费毛片 | 日本一级毛片在线观看 | 国产一区二区三区美女在线观看 | 欧美亚洲一二三区 | a级免费视频 | 国产成人cao在线 | 男女做www免费高清视频 | 中文字幕不卡免费视频 | 亚洲国产第一区 | 国产精品黄网站免费观看 | 欧美日韩在线播放 | a级在线观看 | 三个黑人强一个女人视频 |