色综合图-色综合图片-色综合图片二区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
相關文章:
主站蜘蛛池模板: 欧美日韩精品国产一区在线 | 国产一级高清视频 | 国产精品拍拍拍福利在线观看 | 欧美亚洲综合网 | 日本美女黄网站 | 午夜主播福利视频在线观看 | 欧美高h视频| 成人男女啪啪免费观看网站 | 久久精品亚洲精品国产欧美 | 91小视频在线观看免费版高清 | 成人久久18网站 | 中国胖女人一级毛片aaaaa | 九九热视频在线免费观看 | 在线黄| 免费一级性片 | 欧美一级成人 | 久青草国产手机在线观 | 在线观看片成人免费视频 | 一二三区在线观看 | 国产日韩欧美精品 | 日韩欧美理论 | 欧美日韩免费一区二区在线观看 | 久久视频精品36线视频在线观看 | 色老久久 | 成人精品视频在线观看播放 | 亚洲天堂色视频 | b毛片| 免费国产高清视频 | 国产高清在线免费视频 | 欧美成人手机视频 | 久久99视频精品 | 深夜福利网站在线观看 | 国产精品性视频免费播放 | 日本免费一二区视频 | 亚洲国产精品综合欧美 | 精品国产午夜久久久久九九 | 成人影院欧美大片免费看 | 国产精品久久久久久久久99热 | 天堂一区二区三区在线观看 | 午夜淫片| 亚洲日产2021三区 |