XML DOM attributes 属性
来源:互联网 发布:java实现支付功能 编辑:程序博客网 时间:2024/04/27 19:47
attributes 属性返回包含被选节点属性的个数.
如果被选节点不是元素,则该属性返回 NULL.
提示:该属性仅用于 element 节点
实例
在所有的例子中,我们将使用 XML 文件 books.xml,以及 JavaScript 函数 loadXMLDoc()。
例子 1
下面的代码片段获取 "books.xml" 中第一个 <title> 元素的属性数目:
xmlDoc=loadXMLDoc("books.xml");var x=xmlDoc.getElementsByTagName("book")[0].attributes
;document.write(x.length);
以上代码的输出:
1
例子 2
下面的代码片段输出第一个 <book> 元素中 "category" 属性的值:
xmlDoc=loadXMLDoc("books.xml");var x=xmlDoc.getElementsByTagName("book")[0].attributes
;var att=x.getNamedItem("category");document.write(att.value);
以上代码的输出:
COOKING
TIY
- getNamedItem() 和 属性 - 获取项目的值
- 属性和长度 - 从元素中获取属性的数目
Element 对象参考手册
0 0
- XML DOM attributes 属性
- XML Attributes(XML属性)
- XML DOm属性备忘录
- XML DOM childNodes 属性
- XML DOM tagName 属性
- XML DOM nextSibling 属性
- XML.attributes
- XML Attributes
- XML DOM 属性和方法
- DOM attributes and properties
- html 中的属性(property)以及DOM对象中的attributes的详解
- ASP.NET Attributes属性
- Attributes属Style属性
- 文本属性Attributes
- 详解文本属性Attributes
- Tools属性Tools Attributes
- 文本属性Attributes讲解
- 详解文本属性Attributes
- Linux网络编程:TCP服务器(多进程)
- Codeforces Round #242 (Div. 2) (A、B、C)
- Timus 1723. Sandro's Book 题解
- Spring AOP(二、注解配置实现)
- 线程、进程 的创建
- XML DOM attributes 属性
- Windows编程之非模态对话框
- archlinux 音乐播放器与歌词显示
- apk加密
- action标签传值
- 假如给你一天大数据的生活
- c语言中,字符数组与字符串赋值问题
- C++ 扫盲学习
- 一个人可用的链表操作