使用 firexpath 的 xpath [英] xpath using firexpath
问题描述
我有 firexpath,但它似乎不适用于 xpath.即使是简单的 //div
也不会返回任何结果.即使我单击现有节点,说复制 XPath",然后将该 XPath 粘贴到过滤器输入框中,它也会显示未找到节点".//*[name()='div']
确实有效.我是否缺少命名空间或其他东西?下面是根标签的样子(它是一个有效的 XHTML):
I have firexpath, and it doesn't seem to be working with xpath. Even something simple //div
returns no results. Even if I click on an existing node, say "copy XPath" and then paste that XPath into filter input box, it says "no nodes found". //*[name()='div']
does work though. Am I missing a namespace or something? Here is what root tag looks like (it's a valid XHTML):
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" class="ff ff3">
我没有找到 FireXPath 的支持论坛,所以我把它贴在这里.
I didn't find a support forum for FireXPath, so I'm posting it here.
推荐答案
我没有使用过 firexpath 但它看起来好像是默认的命名空间 xmlns="http://www.w3.org/1999/xhtml"
阻止 xpath 找到 div 作为元素内的 div 元素,该元素无视以该命名空间为前缀的 xmlns.
I have not used firexpath but it looks as though the default namespace xmlns="http://www.w3.org/1999/xhtml"
is preventing xpath from finding the div as the div element inside the element which defies xmlns with be prefixed with that namespace.
因此,您需要使用某种方法调用向 firexpath 注册命名空间???那么 //div
应该可以工作或者你的表达式也很好,如果你想在表达式中考虑命名空间,你可以像这样包含对命名空间的检查
You therefore would need to register the namespace with firexpath using some sort of method call??? then //div
should work or your expression is fine as well, if you were wanting to consider namespaces in the expression you could include a check for the namespace like so
//*[name()='div' and namespace-uri()='http://www.w3.org/1999/xhtml']
我已经下载了 firexpath,它现在被称为 firepath,它看起来不可能注册命名空间,所以看起来你必须使用 name() 方法
I have downloaded firexpath which now is called firepath and it doesn't look possible to register a namespace so it looks like you will have to the name() method
这篇关于使用 firexpath 的 xpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!