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

Raksmart VPS主机如何设置取消自动续费

今天有看到Raksmart账户中有一台VPS主机即将到期,这台机器之前是用来测试评测使用的。这里有不打算续费,这不面对万一导致被自动续费忘记,所以我还是取消自动续费设置。如果我们也有类似的问题,这里就演示截图设置Raksmart取消自动续费。这里我们可以看到上图,在对应VPS主机的【其余操作】中可以看到默认已经是不自动续费,所以我们也不要担心被自动续费的。当然,如果有被自动续费,我们确实不想续费的...

Gcore(75折)迈阿密E5-2623v4 CPU独立服务器

部落分享过多次G-core(gcorelabs)的产品及评测信息,以VPS主机为主,距离上一次分享商家的独立服务器还在2年多前,本月初商家针对迈阿密机房限定E5-2623v4 CPU的独立服务器推出75折优惠码,活动将在9月30日到期,这里再分享下。G-core(gcorelabs)是一家总部位于卢森堡的国外主机商,主要提供基于KVM架构的VPS主机和独立服务器租用等,数据中心包括俄罗斯、美国、日...

Linode十八周年及未来展望

这两天Linode发布了十八周年的博文和邮件,回顾了过去取得的成绩和对未来的展望。作为一家运营18年的VPS主机商,Linode无疑是有一些可取之处的,商家提供基于KVM架构的VPS主机,支持随时删除(按小时计费),可选包括美国、英国、新加坡、日本、印度、加拿大、德国等全球十多个数据中心,所有机器提供高出入网带宽,最低仅$5/月($0.0075/小时)。This month marks Linod...

jscript教程为你推荐
马云将从软银董事会辞职怎样看待马云9月10辞去阿里巴巴董事长,回归教育?免费送q币活动有没有免费送Q币的活动?聚酯纤维和棉哪个好聚酯纤维和棉 那个比较暖和啊骁龙750g和765g哪个好骁龙765G,这里的g是什么意思?麒麟990和骁龙865哪个好骁龙八65和麒麟990谁强一点?骁龙765g和骁龙865哪个好骁龙865八核2.84H和骁龙855plus八核2.96GHZ那个好了?少儿英语哪个好少儿英语哪个好美国国际东西方大学现在去哪国留学最有前途?willyunlee求几近完美演员表,几近完美女主角几近完美男主角是谁?铁通dns服务器地址铁通dns服务器地址
动态域名解析 域名城 免费个人网站申请 小米数据库 刀片式服务器 徐正曦 hktv gtt 带宽租赁 国内域名 阿里dns 攻击服务器 带宽测试 什么是dns 火山互联 crontab 海尔t68驱动 招聘瓦工 流媒体服务器软件 个人web服务器 更多