无法获得特定类的跨度xpath [英] Unable to get xpath of span with a particular class

查看:105
本文介绍了无法获得特定类的跨度xpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法获得以下span元素的xpath:

 < span data-ft =& #123;&安培; QUOT; TN&安培; QUOT;:&安培; QUOT; K&安培; QUOT;&安培;#125; class =userContent>这是此页面的第三篇文章。< / span> 

我已经在这个网址粘贴了xml文件: http://pastebin.com/MfXsYSJQ
(只需按Ctrl + f it)。
我正在尝试以下xpath:

  html / body // span [@ class ='userContent'] 

但是它返回null。那么为什么是这样,我该如何从页面获取它?

解决方案

您的跨度是评论的一部分。您无法为注释内容编写XPath表达式。

编辑进一步说明:
查看您的pastbin代码,搜索范围并查看它是否为评论的一部分。您可以简化使用xmllint --format的工作。您将看到xmllint不会缩进评论的正文。而你的跨度是这样一个不显眼的块的一部分,这是评论的一部分


I am unable to get the xpath of the following span element:

<span data-ft="&#123;&quot;tn&quot;:&quot;K&quot;&#125;" class="userContent">This is the third post of this page.</span>

I have pasted the xml file at this url:http://pastebin.com/MfXsYSJQ (Just ctrl+f it). I am trying the following xpath:

html/body//span[@class='userContent'] 

But its returning null.So why is it so and how should I get it from the page?

解决方案

Your span is part of a comment. You can not write XPath expressions for the contents of comments.

EDIT Further clarification: Look at your pastbin code, search for the span and look if it is part of a comment. You can simplify the job the the use of xmllint --format. You will see that xmllint will not indent the body of the comment. And your span is part of such an unindented block, which is part of a comment

这篇关于无法获得特定类的跨度xpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆