1

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?

rahulserver
  • 10,411
  • 24
  • 90
  • 164

1 Answers1

2

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

rahulserver
  • 10,411
  • 24
  • 90
  • 164
ceving
  • 21,900
  • 13
  • 104
  • 178
  • 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 ``. – ceving Jan 24 '14 at 11:30
  • Ah got it! That solved the problem. But I am surprised to see that it is commented. Its generated using HtmlUnit and works find once I log in to the site.Anyways thats a different issue though. Thanks!! – rahulserver Jan 24 '14 at 11:43