首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xpather不会在Firefox3.5上评估XPath,但在Firefox3.6上运行良好

Xpather不会在Firefox3.5上评估XPath,但在Firefox3.6上运行良好
EN

Stack Overflow用户
提问于 2011-05-30 15:56:34
回答 1查看 423关注 0票数 0

我正在开发一个richface应用程序,并尝试在firefox3.5上使用xpather评估以下xpath。XPather不计算任何xpath,尽管相同的xpath在Firefox3.6上运行得很好。我测试的页面是这样的-

代码语言:javascript
复制
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:o="http://openfaces.org">
  <head>
    <script src="some source" type="text/javascript"></script>
    <script src="some source" type="text/javascript"></script>
    <link class="component" href="some source" rel="stylesheet" type="text/css" />
    <link class="component" href="some source" 
          media="rich-extended-skinning" rel="stylesheet" type="text/css" />
    <link class="component" href="some source" rel="stylesheet" type="text/css" />
    <script type="text/javascript">window.RICH_FACES_EXTENDED_SKINNING_ON=true;</script>
    <link type="text/css" href="some source" rel="stylesheet"/>

  <body class="Banner" onresize="setTreePnlHeight()" onload="loadApp();">
    <input type="hidden" id="dsTreeScrollPos" value="0" />
    <div id="a" class="application"><form id="form" name="form" method="post" action="...">
    ....
  </body>
</html>

如果我使用xpather(v1.4.5)来评估FF3.5上的简单xpath,比如//input,它不会返回任何结果。这个问题是由命名空间引起的吗?如何在FF3.5上验证我的xpath?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-30 19:46:35

//input一样,

在FF3.5上的简单xpath不返回任何结果。这个问题是由命名空间引起的吗?

是。如果您查看您的文档,您会发现其中有一个默认的名称空间定义。

代码语言:javascript
复制
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:o="http://openfaces.org">

这意味着//input查找不带名称空间的元素<input>,而您应该查找http://www.w3.org/1999/xhtml名称空间中的<input>。您需要定义该命名空间并将其绑定到前缀,然后在XPath中使用该前缀。像//x:input一样

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6173656

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档