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

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

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

瀏覽:175日期: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
相關文章:
主站蜘蛛池模板: 久久精品日产高清版的功能介绍 | 最近免费中文字幕在线视频2 | 视频在线一区二区 | 国产成人精品一区二区在线 | www.久久视频 | 蜜桃视频在线观看www社区 | 国产成人精品一区二区三区视频 | 亚洲国产精品一区二区三区 | 在线看免费观看日本 | 黄色一级片在线观看 | 色欧美片视频在线观看 | 资源av | 九九热精品免费视频 | 日韩免费在线观看视频 | 国产特级毛片 | 91精品国产综合久久福利软件 | 日韩精品小视频 | 9久久精品| 成人午夜在线 | 日本a在线 | 国产一区二区三区免费 | 国产一区不卡视频 | 一区二区三区免费在线观看 | 久久久久久黄 | 国产日韩一区 | 亚洲成人一 | 久久国产综合 | 亚州成人 | 操片| 国产黄网 | 日韩专区一区二区三区 | 影音先锋亚洲精品 | 免费成人在线电影 | 中文字幕在线观看的电影 | 欧美日韩三区 | 99国产精品久久久久久久 | 色视频网站在线观看 | 99精品久久久久久久免费 | 国产免费一区 | 99精品欧美一区二区三区 | 91精品久久久久久久久中文字幕 |