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

Spinservers:美国圣何塞服务器,双E5/64GB DDR4/2TB SSD/10Gbps端口月流量10TB,$111/月

spinservers怎么样?spinservers大硬盘服务器。Spinservers刚刚在美国圣何塞机房补货120台独立服务器,CPU都是双E5系列,64-512GB DDR4内存,超大SSD或NVMe存储,数量有限,机器都是预部署好的,下单即可上架,无需人工干预,有需要的朋友抓紧下单哦。Spinservers是Majestic Hosting Solutions,LLC旗下站点,主营美国独立...

spinservers($179/月),1Gbps不限流量服务器,双E5-2630Lv3/64GB/1.6T SSD/圣何塞机房

中秋节快到了,spinservers针对中国用户准备了几款圣何塞机房特别独立服务器,大家知道这家服务器都是高配,这次推出的机器除了配置高以外,默认1Gbps不限制流量,解除了常规机器10TB/月的流量限制,价格每月179美元起,机器自动化上架,一般30分钟内,有基本自助管理功能,带IPMI,支持安装Windows或者Linux操作系统。配置一 $179/月CPU:Dual Intel Xeon E...

buyvm迈阿密机房VPS国内首发测评,高性能平台:AMD Ryzen 9 3900x+DDR4+NVMe+1Gbps带宽不限流量

buyvm的第四个数据中心上线了,位于美国东南沿海的迈阿密市。迈阿密的VPS依旧和buyvm其他机房的一样,KVM虚拟,Ryzen 9 3900x、DDR4、NVMe、1Gbps带宽、不限流量。目前还没有看见buyvm上架迈阿密的block storage,估计不久也会有的。 官方网站:https://my.frantech.ca/cart.php?gid=48 加密货币、信用卡、PayPal、...

jscript教程为你推荐
绝地求生加速器哪个好绝地求生哪个加速器好用一点,求推荐一个杰士邦和杜蕾斯哪个好杰士邦的超薄款跟杜蕾斯的超薄款,哪个舒服点?手机杀毒哪个好手机杀毒软件哪个好 五大手机安全软件杀毒大比拼看书软件哪个好手机阅读软件哪个好用?行车记录仪哪个好请问行车记录仪那个牌子好?p图软件哪个好有什么P图工具比较好用视频软件哪个好安卓系统在线看视频软件哪个好百度空间登录百度空间怎么登陆51个人空间登录我在电脑上用的是Q号登录51个人空间,在手机上怎么却不能用Q号登录51个人空间了辽宁联通网上营业厅辽宁联通网上营业厅为什么不能交小灵通的话费?
虚拟主机推荐 hawkhost优惠码 namecheap linode代购 外贸主机 sugarsync 优key 外国空间 12306抢票助手 全站静态化 双11秒杀 免费高速空间 福建铁通 卡巴斯基免费试用 paypal注册教程 上海服务器 浙江服务器 阿里云邮箱登陆地址 lamp兄弟连 免费个人主页 更多