rahulserver
rahulserver

Reputation: 11205

Unable to get xpath of span with a particular class

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?

Upvotes: 1

Views: 101

Answers (1)

ceving
ceving

Reputation: 23814

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

Upvotes: 2

Related Questions