代码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技术专栏

提速啦(69元起)香港大带宽CN2+BGP独享云服务器

香港大带宽服务器香港大带宽云服务器目前市场上可以选择的商家十分少,这次给大家推荐的是我们的老便宜提速啦的香港大带宽云服务器,默认通用BGP线路(即CN2+BGP)是由三网直连线路 中国电信骨干网以及HGC、NTT、PCCW等国际线路混合而成的高品质带宽(精品带宽)线路,可有效覆盖全球200多个国家和地区。(适用于绝大部分应用场景,适合国内外访客访问,域名无需备案)提速啦官网链接:点击进入香港Cer...

Vultr再次发布充值多少送多少活动

昨天我们很多小伙伴们应该都有看到,包括有隔壁的一些博主们都有发布Vultr商家新的新用户注册福利活动。以前是有赠送100美元有效期30天的,这次改成有效期14天。早年才开始的时候有效期是60天的,这个是商家行为,主要还是吸引到我们后续的充值使用,毕竟他们的体验金赠送,在同类商家中算是比较大方的。昨天活动内容:重新调整Vultr新注册用户赠送100美元奖励金有效期14天今天早上群里的朋友告诉我,两年...

Hostigger不限流量VPS年20美元

Hostigger 主机商在前面的文章中也有介绍过几次,这个商家运营时间是有一些年份,只不过在我们圈内好像之前出现的次数不多。最近这段时间商家有提供不限流量的VPS主机,逐渐的慢慢被人认识到。在前面的介绍到他们提供的机房还是比较多的,比如土耳其、美国等。今天看到Hostigger 商家居然改动挺大的,原来蛮好的域名居然这次连带官方域名都更换掉去掉一个G(Hostiger )。估摸着这个域名也是之前...

jscript教程为你推荐
可爱桌面背景图片求好看的桌面背景图片登陆qq空间首页QQ空间打开就显示主页苹果x和xr哪个好苹果xr好还是苹果x好985和211哪个好211的院校和985的那个好?手机杀毒哪个好手机杀毒软件哪个好手机炒股软件哪个好手机股票交易哪个平台最好51空间登录手机怎么登陆51空间啊google广告申请怎样才能申请google广告东莞电信网上营业厅东莞电信网上营业厅是不是有个宽带团购活动?dns服务器未响应网络dns服务器未响应要怎么解决
济南域名注册 免费试用vps 域名服务器是什么 国外免费域名网站 免费cn域名 bandwagonhost wavecom iisphpmysql 外国域名 表格样式 135邮箱 双十一秒杀 如何用qq邮箱发邮件 中国电信宽带测速器 银盘服务 下载速度测试 国外的代理服务器 贵阳电信 腾讯网盘 免备案cdn加速 更多