当前位置: 代码网 > it编程>网页制作>Xml > jscript与vbscript 操作XML元素属性的代码

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

2024年05月15日 Xml 我要评论
although attributes belong to a particular element, they are not considered child nodes of element n
although attributes belong to a particular element, they are not considered child nodes of element nodes. instead, they behave more like properties of ixmldomelement.

most of the methods for working with attributes come from ixmldomelement. attributes can be manipulated in the following ways.

directly, through the getattribute and setattribute methods of ixmldomelement.

as named ixmldomattribute nodes, with getattributenode and setattributenode.

as a set of nodes accessible through the attributes property and returned as an ixmlnamednodemap.

examples
jscript
the following jscript example creates a new document containing a <memo> element, and then creates an attribute named author with a value of "pat coleman".


vbscript


if you prefer to work with attribute nodes, you can create the attribute, and then create a text node to store its value. attribute nodes can only contain text nodes and entity reference nodes. (if you need to create an attribute containing an entity reference, you must use this approach.)

working with attribute nodes requires using the domdocument object to create attribute and text (and entity reference, if necessary) nodes before assigning the nodes to the element.

jscript
the following jscript code uses this approach to perform the same work as the preceding examples, creating a <memo> element with an author attribute holding the value "pat coleman".



vbscript
(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com