.
is the current node; it is short for self::node()
.
//
is the descendant-or-self axis; it is short for /descendant-or-self::node()/
.
Together, .//
will select along the descendent-or-self axis starting from the current node. Contrast this with //
which starts at the document root.
Example
Consider the following HTML:
<html>
<body>
<div id="id1">
<p>First paragraph</p>
<div>
<p>Second paragraph</p>
</div>
</div>
<p>Third paragraph</p>
</body>
</html>
//p
will select all paragraphs:
<p>First paragraph</p>
<p>Second paragraph</p>
<p>Third paragraph</p>
On the other hand, if the current node is at the div
element (with @id
of "id1"
), then .//p
will select only the paragraphs under the current node:
<p>First paragraph</p>
<p>Second paragraph</p>
Notice that the third paragraph is not selected by .//p
when the current node is the id1
div
because the third paragraph is not under that div
element.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…