代码jscript与vbscript操作ML元素属性的代码

jscript教程  时间:2021-01-29  阅读:()

Although attributes bel ong to a particular eleme nt, they are not con sidered chi ld no des of element no des. In stead, they behave more l ike properties of IXMLDOMEIeme nt.

Most of the methods for work ing with attributes come from IXMLDOMEleme nt.Attributes can bemani pulated in the fol lowi ng ways.

Directly, through the getAttribute and setAttribute methods of IXMLDOMEleme nt.

As named IXMLDOMAttribute nodes,with getAttributeNode and setAttributeNode.

As a set of no des accessible through the attributes property and retur ned as an

IXMLNamedNodeM ap.

Examples

JScript

The fol low ing JScript example creates a new docume nt containing a<mem o>eleme nt,and the n creates an attribute n amed author with a value of "Pat Colema n".

代码如下var xmlDoc=new ActiveXObject("Msxml2.DOMDocume nt.3.0");var rootEleme nt=xmlDoc.createEleme nt("memo");rootEleme nt.setAttribute("author", "Pat Colema n");xmlDoc.appe ndChi ld(rootEleme nt);

VBScript

代码如下

Set xmlDoc=CreateObject("Msxml2.DOMDocume nt.3.0")

Set rootEleme nt=xmlDoc.createEleme nt("memo")rootEleme nt.setAttribute("author", "Pat Colema n")xmlDoc.appe ndChi ld(rootEleme nt)

If you prefer to work with attribute no des,you can create the attribute,and the n create a textnode to store its value.Attribute no des can only contain text no des and en tity reference no des. (If youn eed to create an attribute containing an en tity reference,you must use this approach.)

Worki ng with attribute no des requires using the DOMDocume nt object to create attribute andtext (a nd en tity referen ce, if n ecessary)no des before assig ning the no des to the eleme nt.

JScript

The fol lowi ng JScript code uses this approach to perform the same work as the precedi ngexamples,creating a<memo>element with an author attribute holding the value"Pat Colema n".

代码如下var xmlDoc=new ActiveXObject("Msxml2.DOMDocume nt.3.0");var rootEleme nt=xmlDoc.createEleme nt("memo");var memoAttribute=xmlDoc.createAttribute("author");var memoAttributeText=xmlDoc.createTextNode("Pat Colema n");memoAttribute.appe ndChi ld(memoAttributeText);rootEleme nt.setAttributeNode(memoAttribute);xmlDoc.appe ndChi ld(rootEleme nt);

VBScript

代码如下

Set xmlDoc=CreateObject("Msxml2.DOMDocume nt.3.0")

Set rootEleme nt=xmlDoc.createEleme nt("memo")

Set memoAttribute=xmlDoc.createAttribute("author")

Set memoAttributeText=xmlDoc.createTextNode("Pat Colema n")memoAttribute.appendChi ld(memoAttributeText) rootEleme nt.setAttributeNode(memoAttribute)xmlDoc.appendChi ld(rootEleme nt)

更多信息请查看IT技术专栏

器安装环境和运维管理工具推荐

今天看到一个网友从原来虚拟主机准备转移至服务器管理自己的业务。这里问到虚拟主机和服务器到底有什么不同,需要用到哪些工具软件。那准备在下班之间稍微摸鱼一下整理我们服务器安装环境和运维管理中常见需要用到的软件工具推荐。第一、系统镜像软件一般来说,我们云服务器或者独立服务器都是有自带镜像的。我们只需要选择镜像安装就可以,比如有 Windows和Linux。但是有些时候我们可能需要自定义镜像的高级玩法,这...

白丝云-美国圣何塞4837/德国4837大带宽/美西9929,26元/月起

官方网站:点击访问白丝云官网活动方案:一、KVM虚拟化套餐A1核心 512MB内存 10G SSD硬盘 800G流量 2560Mbps带宽159.99一年 26一月套餐B1核心 512MB内存 10G SSD硬盘 2000G流量 2560Mbps带宽299.99一年 52一月套餐...

onevps:新增(支付宝+中文网站),香港/新加坡/日本等9机房,1Gbps带宽,不限流量,仅需$4/月

onevps最新消息,为了更好服务中国区用户:1、网站支付方式新增了支付宝,即将增加微信;原信用卡、PayPal方式不变;(2)可以切换简体中文版网站,在网站顶部右上角找到那个米字旗,下拉可以换中国简体版本。VPS可选机房有:中国(香港)、新加坡、日本(东京)、美国(纽约、洛杉矶)、英国(伦敦)、荷兰(阿姆斯特丹)、瑞士(苏黎世)、德国(法兰克福)、澳大利亚(悉尼)。不管你的客户在亚太区域、美洲区...

jscript教程为你推荐
游戏内存修改器我下了一个CE就是 游戏内存修改器 ,真心求教怎么用这个刷 蜀门的 金币 QQ986701861金士顿4g内存条金士顿DDR3 4G的内存有什么型号?国内免备案服务器哪里的免备案服务器到国内访问速度快?天气预报哪个好用哪个最准确手机上的天气预报软件,哪个最准,最好用?迈腾和帕萨特哪个好帕萨特和迈腾哪个车好?朗逸和速腾哪个好朗逸和新速腾哪个性能更好点?浮动利率和固定利率哪个好对于企业来说固定利率贷款与浮动利率贷款优缺点各是什么?谢谢了。英语词典哪个好英语词典哪个好网络机顶盒哪个好什么牌子的网络机顶盒最好网页qq空间登录网页查看qq空间
美国网站空间 美国服务器租用 双线vps 网站域名备案 注册cn域名 flashfxp怎么用 stablehost 新世界电讯 徐正曦 静态空间 免费全能主机 metalink 优酷黄金会员账号共享 独享主机 shuang12 智能dns解析 国外免费云空间 好看的空间 腾讯服务器 zencart安装 更多