How to get the first five images from a list of reviews - xpath

I need help in getting the first images from a list of reviews. I have to get just the first images from the first five reviewers. And the reviews look something like this.
<div class='feedback item'>
<dl class='buyer-review'>
<dd class='photo-list'>
<ul>
<li> <img> </li>
<li> <img> </li>
<li> <img> </li>
</ul>
</dd>
</dl>
<dl class='buyer-additional-review'>
<dd class='photo-list'>
<ul>
<li> <img> </li>
<li> <img> </li>
<li> <img> </li>
</ul>
</dd>
</dl>
</div>
Sometimes there is an additional review, and sometimes none. Sometimes, the image can be found in the additional review and not in the main review. The thing that I need to do is get just one image from each reviewer.
I tried doing something like this:
//div[position()<6]/dl/dd//ul/li[1]/img
This gets the images from the first five reviewers, but sometimes it returns more than 5 images if there's an image in the main review and in the additional review.
So I tried doing something like this:
//div[position()<6]/dl[1]/dd//ul/li[1]/img
But sometimes it returns less than 5 images if the image is located in the additional review and not in the main review.
Essentially, I just need to get one image per reviewer, and it doesn't matter if it's from the main review or from the additional review.
thank you in advance!

Try this : //div/dl[position()<6]/dd/ul/li[1]/img
you have to take position of dl not div as it seems from your xml.

Try these:
(//div[position()<6]//img)[1]
//div[position()<6]/dl[.//img][1]//img

Related

Additional image in bootstrap navbar

I try to study a Bootstrap 3 last three months.
All fine, but I would like to put in my navbar the additional image (in right side of it).
In my opinion, to insert a picture directly in HTML code like:
picture
- bad idea, and I created a with a background picture, specified through CSS, but the picture does not appear on the page ...
How can I do it?
And possible whether to do it at all?
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="Brand" src="...">
</a>
</div>
</div>
</nav>
Follow this guide
http://getbootstrap.com/components/#navbar-brand-image
To have an additional image on the other side of the menu, you just need to put it as part of the link menu. See example:
http://jsbin.com/mupobo/edit?html,output

Google Analytics Events for li items

I'm trying to add Google Analytics click tracking events to li list items (active thumbnails) used in a responsive grid application, and can't get it working. I've researched here and in the Google developer forums without success. I'm sure there is something simple I'm doing wrong. I have the latest GA script code installed (page view analytics are working fine). Here is a code sample:
<ul>
<li data-type="link" data-url="http://www.dianagabaldon.com/books/outlander-series/" data-target="_self" >
</li>
<li data-thumbnail-path="outlander_files/thumbnails/outlanderbookseries1.png" ></li>
<li data-thumbnail-text >
<p class="largeLabel" >Diana Gabaldon - Outlander Series</p></li>
</ul>
Hope you can help. Feel free to suggest a better way of doing it.
Update: I'm still digging, and the GA code has been updated for Universal Analytics and looks like this:
<ul>
<li data-type="link" data-url="http://www.dianagabaldon.com/books/outlander-series/" data-target="_self" >
</li>
<li data-thumbnail-path="outlander_files/thumbnails/outlanderbookseries1.png" ></li>
<li data-thumbnail-text >
<p class="largeLabel" >Diana Gabaldon - Outlander Series</p></li>
</ul>
Update 2: I tried opening the outbound link target in a new page to see if a lack of callBack might be the problem. No success. Following are two views of the code, one with the contained inside the li with the outbound link, the other in a separate li with the same parent ul. Neither works. Does anyone know which syntax is correct? Thx.
Example 1: With href in it's own li:
<ul>
<li></li>
<li data-type="link" data-url="http://www.dianagabaldon.com/books/outlander-series/" data-target="_blank" ></li>
<li data-thumbnail-path="outlander_files/thumbnails/outlanderbookseries1.png" ></li>
<li data-thumbnail-text >
<p class="largeLabel" >Diana Gabaldon - Outlander Series</p></li>
</ul>
Example 2: With href inside outbound link li:
<ul>
<li data-type="link" data-url="http://www.starz.com/outlandercommunity/home.html" data-target="_blank" >
</li>
<li data-thumbnail-path="outlander_files/thumbnails/community1.png" ></li>
<li data-thumbnail-text >
<p class="largeLabel" >Starz: Outlander Community</p></li>
</ul>
The syntax you are using for the event tracking uses the classic GA syntax (_gaq.push), but if you are using Universal Analytics (assuming that is what you mean by using the "latest GA script code"), the syntax needs to be updated:
onClick="ga('send', 'event', 'GridLinks', 'Click', 'Outlander Clicks 1');"
I'm not familiar with Responsive Grid, but the likely explanation is that the call to ga only adds the event to a queue for asynchronous processing, and that the event is lost because the current document is immediately replaced afterwards (stopping the JavaScript execution for the current page). You would need to use a hit callback as described in the Google Analytics help, but I'm not sure how this would be integrated with Responsive Grid. Also note that there are a couple of other pitfalls you need to be aware of.

Microdata: How to indicate multiple awards in the UL tag?

I wonder if we can repeat the same itemprop in the same itemtype, e.g.:
<ul itemscope itemtype="http://schema.org/Person">
<li itemprop="award">Award 1</li>
<li itemprop="award">Award 2</li>
<li itemprop="award">Award 3</li>
</ul>
Is this a right way to specify awards using Microdata? How about the use of the itemprop awards instead? Thanks in advance!
It's fine as you wrote it, multiple values are allowed in microdata.
I find this handy to test this kind of stuff. It extracts all the awards from your snippets, so it's good!
As you can see in the schema.org documentation, awards is a legacy spelling and should no longer be used.
Update: Oh and welcome to StackOverflow by the way :-)

How can I display rhinoslider caption in combination with lightbox2?

I have a fully working rhinoslider and lightbox2. The images slide but are also clickable, when there clicked the nice lightbox2 pops up. But for some reason the captions in the slider won't display when the other link is above it.
My code:
<ul id="slider"><li><img src="images/1.jpg" alt="" title="test" /></li> </ul>
Does anyone know why the captions won't display? And is there a solution to this problem?
http://rhinoslider.com/
http://lokeshdhakar.com/projects/lightbox2/
First of all you should fix your markup.
<ul id="slider">
<li>
<a href="images/1big.jpg" rel="lightbox[roadtrip]" title="test">
<img src="images/1.jpg" alt="" title="test" />
</a>
</li>
</ul>
If the caption won't work afterwards, please make sure you enabled them in the settings of Rhinoslider.
If they still won't work try to set the captions manually: http://rhinoslider.com/tricks/html-captions/

Unwanted ftp surprises

Sometimes, when I upload files to ftp, and then download them, I face with some "unwanted tricks" inside gotten files.
Initial file:
<ul>
<li>Home</li>
<li>Works</li>
<li>About</li>
<li>Docs</li>
<li>Blog</li>
<li>Forums</li>
</ul>
2 examples:
1) Unwanted blank lines.
When I get files back, code becomes look like:
<ul>
<li>Home</li>
<li>Works</li>
<li>About</li>
<li>Docs</li>
<li>Blog</li>
<li>Forums</li>
</ul>
2) Tabulation clearing:
Code transforms to:
<ul><li>Home</li><li>Works</li><li>About</li><li>Docs</li><li>Blog</li><li>Forums</li></ul>
Why it happens and how to to beat these surprises?
Make sure your transfer type is correct. In other words, ASCII or auto.

Resources