无法获得特定类的跨度xpath [英] Unable to get xpath of span with a particular class
问题描述
我无法获得以下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="{"tn":"K"}" 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屋!