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

Vultr新用户省钱福利,最新可用优惠码/优惠券更新

如今我们无论线上还是线下选择商品的时候是不是习惯问问是不是有优惠活动,如果有的话会加速购买欲望。同样的,如果我们有准备选择Vultr商家云服务器的时候,也会问问是不是有Vultr优惠码或者优惠券这类。确实,目前Vultr商家有一些时候会有针对新注册用户赠送一定的优惠券活动。那就定期抽点时间在这篇文章中专门整理最新可用Vultr优惠码和商家促销活动。不过需要令我们老用户失望的,至少近五年我们看到Vu...

注册做什么96%可以干啥,常用的7个常用的国内国外域名注册服务商_云服务器可以干什么

日前,国内知名主机服务商阿里云与国外资深服务器面板Plesk强强联合,推出 阿里云域名注册与备案、服务器ECS购买与登录使用 前言云服务器(Elastic  只需要确定cpu内存与带宽基本上就可以了,对于新手用户来说,我们在购买阿里云服务申请服务器与域名许多云服务商的云服务器配置是弹性的 三周学会小程序第三讲:服务 不过这个国外服务器有点慢,可以考虑国内的ngrokcc。 ngrokcc...

PacificRack(年付低至19美元),夏季促销PR-M系列和多IP站群VPS主机

这几天有几个网友询问到是否有Windows VPS主机便宜的VPS主机商。原本他们是在Linode、Vultr主机商挂载DD安装Windows系统的,有的商家支持自定义WIN镜像,但是这些操作起来特别效率低下,每次安装一个Windows系统需要一两个小时,所以如果能找到比较合适的自带Windows系统的服务器那最好不过。这不看到PacificRack商家有提供夏季促销活动,其中包括年付便宜套餐的P...

jscript教程为你推荐
桌面背景图片大全手机壁纸图片大全涡轮增压和自然吸气哪个好发动机涡轮增压好还是自然吸气好法兰绒和珊瑚绒哪个好珊瑚绒和法兰绒哪个暖和江门旅游景点哪个好玩的地方江门有什么地方好玩的?二手车网站哪个好二手车交易网哪个好?加速器哪个好主流加速器哪个好手机杀毒哪个好手机杀毒软件哪个最好用海克斯皮肤哪个好摄魂使者薇恩和海克斯安妮皮肤哪个好 怎么合成雅思和托福哪个好考托福好考还是雅思好考?qq空间登录电脑手机上怎么登陆电脑版QQ空间
域名备案网站 外国空间 服务器日志分析 商家促销 php空间推荐 国外代理服务器地址 亚马逊香港官网 电信主机 最漂亮的qq空间 太原联通测速 重庆电信服务器托管 789 云营销系统 帽子云排名 双线空间 学生服务器 徐州电信 supercache 黑科云 美国西雅图独立 更多