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

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

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

瀏覽:174日期: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
相關文章:
主站蜘蛛池模板: 国产成人精品免费视频网页大全 | 欧美一级免费片 | 国产高清无专砖区2021 | 免费一级毛片女人图片 | 亚洲一区二区三区四区五区 | 美日韩一区二区 | 久久99精品久久久久久久野外 | 91福利国产在线观一区二区 | 欧美日韩偷拍自拍 | 国产欧美亚洲精品一区 | 日韩精品一区二区三区视频网 | 国产日产久久高清欧美一区 | 欧美在线一区二区三区 | 成人免费影院 | 91成人爽a毛片一区二区 | 1769视频在线观看国产 | 国产精品午夜性视频网站 | 国产高清免费不卡观看 | 亚洲一区二区三 | 国产91香蕉视频 | 国产浮力第一页草草影院 | 国产综合成人久久大片91 | 国产在线拍揄自揄视精品不卡 | 美国的毛片免费的 | 欧美另类视频在线观看 | 狠狠色丁香婷婷久久综合不卡 | 亚洲欧美日韩在线精品一区二区 | 呦女精品视频 | 欧美做爰孕妇群 | 日本wwxx色视频 | 91香焦国产线观看看免费 | 国产青草 | 九九色综合网 | 国产猛烈无遮掩视频免费网站男女 | 日韩美女免费线视频 | 91挑色| 久久久久久久久一次 | 99在线免费观看 | 久久亚洲国产 | 亚洲高清免费在线观看 | 黄色美女网站在线观看 |