XPath: First occurrence of class, then retrieving following URL

frankm

New Member
Just had a question about some XPath query string. I want to find the first occurrence of the class="image", and then I want the image source directly following it. For instance, \[code\]<td colspan="2" style="text-align: center"><a href="http://stackoverflow.com/wiki/File:Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg" class="image"><img alt="" src="http://stackoverflow.com//upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg/220px-Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg" width="220" height="263" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg/330px-Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg/440px-Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg 2x" /></a></td></tr>\[/code\]I am trying to retrieve the img src, following the first occurrence of the class="image". So in this example, I really want\[code\]//upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg/220px-Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg\[/code\]
 
Back
Top