logo 西林@生存 - 骑猪闯天下!
XPath 笔记: XPathResult
2008-4-8 0:02:00 By:xling

1,ANY_TYPE 0

Passes this value to Document.evaluate( ) or XPathExpression.evaluate( ) to specify that any

type of result is acceptable. The resultType property is never set to this value.
返回不确定类型。该方法返回的类型由表达式计算的结果决定。

 

2,NUMBER_TYPE 1

numberValue holds the result.
返回数字值

 

3,STRING_TYPE 2

stringValue holds the result.
返回字符串值

 

4,BOOLEAN_TYPE 3

booleanValue holds the result.
返回布尔值。


5,UNORDERED_NODE_ITERATOR_TYPE 4

The result is an unordered set of nodes, which can be accessed sequentially by calling

iterateNext( ) repeatedly until it returns null. The document must not be modified during

this iteration.
返回可以遍历的节点集合,然而,节点的顺序与其在文档中出现的顺序不一定一致。

 


6,ORDERED_NODE_ITERATOR_TYPE 5

The result is a list of nodes, arranged in document order, which can be accessed

sequentially by calling iterateNext( ) repeatedly until it returns null. The document must

not be modified during this iteration.
返回文档顺序的节点集合(使用iterateNext()方法遍历)。因此,可以容易地访问集合中每个独立的节

点。

 


7,UNORDERED_NODE_SNAPSHOT_TYPE 6

The result is a random-access list of nodes. The snapshotLength property specifies the

length of the list, and the snapshotItem( ) method returns the node at a specified index.

The nodes may not be in the same order they appear in the document. Since this kind of

result is a "snapshot," it remains valid even if the document is changed.
返回无序快照节点集合。任何对文档中节点的修改都不影响结果。

 

8,ORDERED_NODE_SNAPSHOT_TYPE 7

The result is a random-access list of nodes, just like UNORDERED_NODE_SNAPSHOT_TYPE, except

that this list is arranged in document order.
返回文档顺序的节点集合(结果集合的快照)。任何对文档中节点的修改都不影响结果。

 


9,ANY_UNORDERED_NODE_TYPE  8

The singleNodeValue property refers to a node that matches the query or null if no nodes

matched. If more than one node matches the query, singleNodeValue may be any one of the

matching nodes.
返回通过singleNodeValue属性访问的某个节点的节点集合,如果没有匹配的节点,那么返回null。返回

的节点集合不一定按出现的顺序排列。

 

10,FIRST_ORDERED_NODE_TYPE 9

singleNodeValue holds the first node in the document that matched the query, or null if no

nodes matched.
返回某个节点的节点集合。该节点使用XPathResult类的singleNodeValue属性访问。返回的节点是文档中

第一个出现的节点。

 

 


XPathResult 实例的属性:

Many of these properties are valid only when resultType holds a particular value. Accessing

properties that are not defined for the current resultType causes an exception.

1,readonly boolean booleanValue
Holds the result value when resultType is BOOLEAN_TYPE.


2,readonly boolean invalidIteratorState
Is TRue if resultType is one of the ITERATOR_TYPE constants and the document has been

modified (当DOM被修改,值为真??), making the iterator invalid, because the result was

returned.


3,readonly float numberValue
Holds the result value when resultType is NUMBER_TYPE.


4,readonly short resultType
Specifies what kind of result the XPath query returned. Its value is one of the constants

listed earlier. The value of this property tells you which other properties or methods you

can use.
返回上面所说的常量中的一个??


5,readonly Node singleNodeValue
Holds the result value when resultType is XPathResult.ANY_UNORDERED_NODE_TYPE or

XPathResult.FIRST_UNORDERED_NODE_TYPE.

 

6,snapshotLength
Specifies the number of nodes returned when resultType is UNORDERED_NODE_SNAPSHOT_TYPE or

ORDERED_NODE_SNAPSHOT_TYPE. Use this property in conjunction with snapshotItem( ).


7,stringValue
Holds the result value when resultType is STRING_TYPE.

 


方法:
1,iterateNext( )
Returns the next node in the node set. Use this method if the resultType is

UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE.


2,snapshotItem( )
Returns the node at the specified index in the list of result nodes. This method may be used

only if resultType is UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE. Use the

snapshotLength property in conjunction with this method.

 

说明:

To use an XPathResult, first check the resultType property. It will hold one of the

XPathResult constants. The value of this property tells you which property or method you

need to use to determine the result value. Calling methods or reading properties that are

not defined for the current resultType causes an exception.

用 XPathResult 之前,请先检查属性: resultType,它的值是 XPathResult所定义的常量。通过这个值

,可以判断结果集。

 

转我的贴,写你的名,是一种可耻的行为!请不要让我BS你!
阅读全文 | 回复(0) | 引用通告 | 编辑

发表评论:

    密码:
    主页:
    标题:
    页面数据正在载入...
<<  < 2008 - >  >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Placard
请职:PHP或JS都行,如果学历要求本科的,请直接忽略。谢谢。 有意者请联系:1fairy1#163.com
Logon System
Search
Info about this blog
Others
myDream
JGrid

数据表格
JTree

树状控件
JMenuTab

标签控件(滑动门)
JTrackBar / JScroll

滑动条/模拟滚动条
JAccordion

(QQ菜单)
关于:
xling,也叫xlingFairy 艾克司令 西林.
Email:1fairy1#163.com
喜欢javascript,喜欢java(汗...还在学习中...水平菜的要死...)
bxna 京ICP备05002321号