我正在研究XPath轴,我已经理解以下所有轴:
'ancestor'(祖先)
| 'ancestor-or-self'(祖先或自身)
| 'attribute'(属性)
| 'child'(子代)
| 'descendant'(后代)
| 'descendant-or-self'(后代或自身)
| 'following'(后继兄弟节点)
| 'following-sibling'(后继同级节点)
| 'parent'(父节点)
| 'preceding'(前驱节点)
| 'preceding-sibling'(前驱同级节点)
| 'self'(自身)
我唯一不明白的是:
| 'namespace'(命名空间)
有没有人能给我一个好的例子和理解,说明'namespace'实际上是做什么用的?
例如:
或者
HTML代码
<a style="left:-1000em;position:absolute" href="/setprefs?suggon=2&prev=https://www.google.co.in/&sig=0_ujdR1PrGxEbi_EiD6RbIb4VvaXc%3D">Screen-reader users, click here to turn off Google Instant.</a>
我正在尝试以下xpath表达式
//a[@style='left:-1000em;position:absolute']/namespace::*[name()='google']
我在上面的命名空间中做错了什么?
此外,我还想知道axes | 'attribute'的用途是什么。在哪种情况下它有帮助?