To get a list of all images (actually, all the values from the src
attributes) inside this ul
, in your case, you can use XPath Axes:
//ul[@id='product-slider']/descendant::img/@src
What this does is:
/ul[@id='product-slider']
selects the ul
element with id='product-seller'
/descendant::img
selects all the descendants (children, grandchildren, etc.) from the ul
/@src
selects the src
attribute of each one of these descendants.
XPath Axes is a great tool, you can find more information about it in here: http://www.w3schools.com/xpath/xpath_axes.asp (I know they're not the most relliable source for everything, but this XPath tutorial is quite a good intro).
Edit: Using OP's new code snippet from codepad as an example:
The captured element inside the source code from Snapdeal Link is the following ul
, in which only the first img
tag contains a src
attribute.
<ul id="product-slider" class="mainImageSlider">
<li>
<img title="Apple iPhone 5S 16 GB (Gold)" class="jqzoom zoomPad lazyBg" itemprop="image" src="http://n2.sdlcdn.com/imgs/a/j/x/large/Apple-iPhone-5S-16-GB-SDL218153659-1-d5617.jpg" width="310" height="363" alt="Apple iPhone 5S 16 GB (Gold)" bigimage="http://n4.sdlcdn.com/imgs/a/j/x/Apple-iPhone-5S-16-GB-SDL218153659-1-d5617.jpg">
</li>
<li>
<img title="Apple iPhone 5S 16 GB (Gold)" class="jqzoom zoomPad lazyBg" lazySrc="http://n1.sdlcdn.com/imgs/a/j/x/large/Apple-iPhone-5S-16-GB-SDL218153659-2-af89e.jpg" width="310" height="363" alt="Apple iPhone 5S 16 GB (Gold)" bigimage="http://n1.sdlcdn.com/imgs/a/j/x/Apple-iPhone-5S-16-GB-SDL218153659-2-af89e.jpg">
</li>
<li>
<img title="Apple iPhone 5S 16 GB (Gold)" class="jqzoom zoomPad lazyBg" lazySrc="http://n4.sdlcdn.com/imgs/a/p/0/large/Apple-iPhone-5S-16-GB-SDL218153659-3-14019.jpg" width="310" height="363" alt="Apple iPhone 5S 16 GB (Gold)" bigimage="http://n4.sdlcdn.com/imgs/a/p/0/Apple-iPhone-5S-16-GB-SDL218153659-3-14019.jpg">
</li>
<li>
<img title="Apple iPhone 5S 16 GB (Gold)" class="jqzoom zoomPad lazyBg" lazySrc="http://n4.sdlcdn.com/imgs/a/p/0/large/Apple-iPhone-5S-16-GB-SDL218153659-4-fa8f3.jpg" width="310" height="363" alt="Apple iPhone 5S 16 GB (Gold)" bigimage="http://n4.sdlcdn.com/imgs/a/p/0/Apple-iPhone-5S-16-GB-SDL218153659-4-fa8f3.jpg">
</li>
</ul>
</div>