av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

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

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

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


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

復(fù)制代碼 代碼如下:
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
復(fù)制代碼 代碼如下:
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)文章:
主站蜘蛛池模板: 久久久久免费 | 亚洲一区二区在线免费观看 | 亚洲国产免费 | 国产白丝精品91爽爽久久 | 五月天激情国产综合婷婷婷 | 亚洲精品久久久久久久久久久 | 男女久久久 | 久久久亚洲精品视频 | www.黄色网 | 四虎毛片 | 国产精品自在线 | 高清一级片 | 久久精品在线 | 日韩不卡一区二区 | 夜夜躁狠狠躁日日躁av | 国产精品日韩在线 | 天天干在线观看 | 日韩黄色一级 | 婷婷久| 触手繁殖の地狱3d啪啪 | 国产精品久久久久久久久久 | 欧美性大战xxxxx久久久 | 中国黄色一级片 | a级在线观看 | 激情小说亚洲 | 亚洲经典av | 久久夜色精品国产欧美乱极品 | 色婷婷基地 | 嫩草在线视频 | 欧美特黄一级片 | 久久久久久亚洲精品 | 日韩精品小视频 | 夜夜操夜夜 | 国内自拍一区 | 国产精品久久久久久久成人午夜 | 亚洲免费观看视频 | 伊人久久中文字幕 | 欧美激情一二三区 | 国产永久视频 | 色婷婷中文字幕 | 精品国产一区二区三区久久久蜜月 |