public class ElementIterator extends Object implements Cloneable
elementiterator,顾名思义,遍历元素树。构造函数可以用文档或元素作为参数来调用。如果构造函数是一个文件作为参数的迭代根文件返回值调用。getdefaultrootelement()。迭代发生在深度优先的方式。关于边界条件的处理:a)如果next()之前first()或current()称,根会回来。b)next()返回null表示列表的末尾。C)previous()返回null如果当前元素是根或next()返回null。的elementiterator没有锁定的元素树。这意味着它不跟踪任何变化。这是这个类的用户的责任,以确保在元素迭代过程中不会发生任何更改。简单的使用例子:public void iterate() { elementiterator =新elementiterator(根);元素的元素;而(true){ if((elem = next())!= null){ //过程元系统。出来。println(”元素:“+元素。getname());} } } } {打破别人;
Constructor and Description |
---|
ElementIterator(Document document)
创建一个新的elementiterator。
|
ElementIterator(Element root)
创建一个新的elementiterator。
|
public ElementIterator(Document document)
document
-文档。
public ElementIterator(Element root)
root
-根元素。
public Object clone()
public Element first()
public int depth()
public Element current()
null
元如果根元素是
null
public Element next()
null
。
public Element previous()
Element
如果可用
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.