Exclude node from XPATH results - xpath

I try to extract each text() from within the below div tags, but without the text() in between the a tag.
I used this with no success:
//div[#class="availability"]/*[not(self::a)]/text()
This is the html
<div class="availability">
Available. Delivered from UK <br>Click for more
</div>
<div class="availability">
Available. Delivered from HK <br>Click for more
</div>
<div class="availability">
Available. Delivered from USA <br>Click for more
</div>
<div class="availability">
Available. Delivered from DE <br>Click for more
</div>
Thanks for guiding me into the right direction!

//div[#class="availability"]/text()

Related

Kendo UI TabStrip Helper

I am newbie in Telerik (Kendo). I want to know how can I hide or show tab based on roles or authentication as per user. I guess its been done by Helper, but I am not sure how to do it.
Please help me regarding this.
Thanks in advance.
Regards,
DS
Its a bit difficult to provide you with the best answer without seeing what you have so far, but if your initializing the TabStrip using JavaScript you will have a list if tabs in your html:
<div id="example">
<div id="tabstrip">
<ul>
<li id="TabParis" class="k-state-active">
Paris
</li>
<li id="TabNewYork">
New York
</li>
<li id="TabLondon">
London
</li>
</ul>
<div>
<div class="weather">
<h2>17<span>ºC</span></h2>
<p>Rainy weather in Paris.</p>
</div>
<span class="rainy"> </span>
</div>
<div>
<div class="weather">
<h2>29<span>ºC</span></h2>
<p>Sunny weather in New York.</p>
</div>
<span class="sunny"> </span>
</div>
<div>
<div class="weather">
<h2>21<span>ºC</span></h2>
<p>Sunny weather in London.</p>
</div>
<span class="sunny"> </span>
</div>
</div>
Give each of the tab list items an id.
Then simply show or hide the list item by Id using JQuery
$('#TabNewYork').hide()
Here is a working example in JSFiddle: http://jsfiddle.net/loanburger/9mLz5wnc/

schema.org with data scattered over page

I would like to add schema.org markup to a product page. So basically all of the page is wrapped in a: <div itemscope itemtype="http://schema.org/Product">
The page shows the name of the product which I mark with itemprop="name", it shows an image which I mark with itemprop="image" etc.
In order to markup the price and the category of the item, I use http://schema.org/Offer. The problem is that price and category are displayed in different parts of the webpage. Is it OK to use itemtype=http://schema.org/Offer twice as in the following example?
<div itemscope itemtype="http://schema.org/Product">
<span itemprop="name">Name of product</span>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<span itemprop="category">animals</span>
</div>
<img itemprop="image" src="#"/>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<span itemprop="price">1000 EUR</span>
</div>
</div>
Don’t use http://schema.org/Offer twice. You are creating two offers that way.
The solution proposed by user1769790 may work for you, but note that the image will be associated with both, the Product and the Offer (which may or may not be what you want).
You could use the itemref attribute instead. See my answer on a similar question on Webmasters SE.
It could look like:
<div itemscope itemtype="http://schema.org/Product" itemref="foobar-image">
<span itemprop="name">Name of product</span>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer" itemref="foobar-price">
<span itemprop="category">animals</span>
</div>
</div>
<img itemprop="image" id="foobar-image" src="" alt="" />
<div itemprop="price" id="foobar-price">1000 EUR</div>
Check if this answered your Question.
http://www.google.com/webmasters/tools/richsnippets?q=uploaded:8004e75474f6bc632c2a56ed33ba1d90
Enclose Product on the entire page. img is common for both product and offer. the solution considers image url for each category (Offer).
<div itemscope itemtype="http://schema.org/Product">
<span itemprop="name">Name of product</span>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<span itemprop="category">animals</span>
<img itemprop="image" src="#"/>
<span itemprop="price">1000 EUR</span>
</div>
</div>
I can help; if you can add more details of your page.

Rich Snippet AggregateRating on type Place

According to schema.org Place should support AggregateRating.
But when I use this snippet:
<div class="row-fluid rating-summary" itemscope itemtype="http://schema.org/Place">
<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<span itemprop="ratingValue">4.5</span>
<span itemprop="bestRating">5</span>
<span itemprop="ratingCount"21</span>
</div>
</div>
Googles Rich Snippet tester won't display the rating until I exchange Place with Product. That’s of course wrong.
I can solve this by using
itemscope itemtype="http://schema.org/WebPage"
on the body but I would really like to know what’s the best way to integrate Rating for Rental Properties.
Try smth like this
<div itemscope itemtype="http://schema.org/Review">
<div itemprop="reviewRating" itemscope itemtype="http://schema.org/AggregateRating">
Avg. Rating:
<span itemprop="ratingValue">9</span>
<meta itemprop="bestRating" content="10"/>
<span itemprop="ratingCount">4</span> Reviews
</div>
<div itemprop="itemReviewed" itemscope itemtype="http://schema.org/Place">
<a itemprop="url" href="wells-fargo-center.html">
Wells Fargo Center
</a>
<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<span itemprop="addressLocality">Philadelphia</span>,
<span itemprop="addressRegion">PA</span>
</div>
</div>
</div>
As you see the idea is to put Place inside Review. Google gives stars for that.
Not so nice as for me but works.

Marking up HTML code with microdata when there are multiple products on a page

I have a page which compares 4 products at a time in parallel tabular form i.e. It mentions features of each of them one after another. Here is a sample page .
I wish to tag these features so that it becomes easier for search engines to interpret. However, in all the examples given here, you have to mention all the features of a product at a time in a div. This causes a problem for my case, where I mention the features of product together.
A typical example as given goes like this :-
<div itemscope itemtype="http://schema.org/Offer">
<span itemprop="name">Blend-O-Matic</span>
<span itemprop="price">$19.95</span>
</div>
However, I would like it to be in this way :-
<div itemscope itemtype="http://schema.org/Offer">
<span itemprop="name">Blend-O-Matic</span> // Item 1
</div>
<div itemscope itemtype="http://schema.org/Offer">
<span itemprop="name">Blend-O-Matic2</span> // Item 2
</div>
Further followed by :-
<div itemscope itemtype="http://schema.org/Offer">
<span itemprop="price">$19.95</span> // Item 1
</div>
<div itemscope itemtype="http://schema.org/Offer">
<span itemprop="price">$21.95</span> // Item 2
</div>
So, in nutshell, is there a way so that I can tag an item with some code and then use it to refer to other details of that item ?
Please comment if I am unclear in asking my doubt !
Use itemref:
<div itemscope itemtype="http://schema.org/Offer" itemref="item1_price">
<span itemprop="name">Blend-O-Matic</span>
</div>
<div id="item1_price">
<span itemprop="price">$19.95</span>
</div>
See results from Google Structured Data Testing Tool here
You might want to have a look at this for SERP. It shows how to have multiple products in a "ItemList"
http://scottgale.com/schema-org-markup-serp/2013/03/17/
Hth
PS: This works without error or issue on the Google Structured Data testing tool over at http://www.google.com/webmasters/tools/richsnippets
But)))
If to be more realistic - You always have WebPage itemtype yes?
So if you have it we have about this:
<div itemscope="" itemtype="http://schema.org/WebPage">
<div itemscope itemtype="http://schema.org/Offer" itemref="item1_price">
<span itemprop="name">Blend-O-Matic</span>
</div>
<div id="item1_price">
<span itemprop="price">$19.95</span>
</div>
</div>
See the google result
And we have a mistake. If we add the same itemscope="" itemtype="http://schema.org/Offer" we will have one full offer and one duplicate with only price. Code:
<div itemscope="" itemtype="http://schema.org/WebPage">
<div itemscope="" itemtype="http://schema.org/Offer" itemref="item1_price">
<span itemprop="name">Blend-O-Matic</span>
</div>
<div itemscope="" itemtype="http://schema.org/Offer">
<span id="item1_price" itemprop="price">$19.95</span>
</div>
</div>
Google result
So we need a different way as I understand, am I right?

How to use regular expression clear content inside div

I have this code
<div class="kakaa">
<div class="hihi">
<div>dfsfsdf</div>
<div class="haha">
<div id="kaka">ohfoehwf</div>
</div>
</div>
<div class="main">
<div>lorem</div>
</div>
</div>
Now, i want to remove div has class hihi, how to do it become
<div class="kakaa">
<div class="main">
<div>lorem</div>
</div>
</div>
You didn't specify if you're doing this on server-side or client-side. If client-side, no regex is necessary. Use jQuery:
$('.hihi').remove();
Here's a reference: http://api.jquery.com/remove/
If you're doing it server-side, don't use regex (you'll never be able to cover all the possibilities in an HTML tag with regex). Instead use a HTML DOM parser. Here's a very simple one: http://simplehtmldom.sourceforge.net/

Resources