当前位置: 首页 > 网络学院 > XML相关教程 > XML DOM > removeNamedItem() 方法

XML DOM
DOM Attribute
DOM Text
DOM CDATA
DOM Comment
DOM HttpRequest
DOM ParseError
DOM 校验器
DOM 介绍
DOM 摘要
DOM 案例
DOM 节点树
DOM 访问节点树
DOM 节点信息
DOM 文档执行
DOM 节点导航

XML DOM 中的 removeNamedItem() 方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 368 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The removeNamedItem() method removes the specified node.
removeNamedItem() 方法的作用是删除指定的节点。

If the removed attribute has a default value, a new attribute immediately appears containing the default value as well as the namespace URI, local name, and prefix, if any.
如果删除的属性是一个默认值。那么新的属性将直接包含默认值、命名空间URI、本地名称和前缀等等。

This method returns the removed node.
这个方法将返回已删除的节点。

Syntax
语法

removeNamedItem(nodename)

Parameter
参数
Description
描述
nodename The name of the node to remove
指定删除的节点名称
 

In all examples, we will use the XML file books.xml, and the JavaScript function loadXMLDoc().
在所有案例中,我们将使用“books.xml”文件以及JavaScript 函数“loadXMLDoc()”。

Example
案例

The following code fragment loops through the <book> elements and removes the category attributes:
下面的代码片断将通过循环语句删除<book>元素中的category属性值:

xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++) { x.item(i).attributes.removeNamedItem("category"); }


Try-It-Yourself Demos
自我演示

removeNamedItem() - Remove an item
removeNamedItem() - 删除一个项

评论 (0) All

登陆 | 还没注册?