Nokogiri/Mechanize extraction of a div content? - ruby

I am parsing a rating site to find out which ratings a given company has.
The ratings can vary between 1 and 5, and they can all be extracted with this code:
a = Mechanize.new
page = a.get(url)
reviews = page.search(".reviewcontent")
reviews.each do |r|
rating = r.at_css(".s1, .s2, .s3, .s4, .s5")
puts rating # => <span class="s5" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
<meta itemprop="worstRating" content="1">
<meta itemprop="bestRating" content="5">
<meta itemprop="ratingValue" content="5"></span>
puts rating.inspect # => #<Nokogiri::XML::Element:0x3fe0e108783c name="span" attributes=[#<Nokogiri::XML::Attr:0x3fe0e1087440 name="class" value="s5">, #<Nokogiri::XML::Attr:0x3fe0e108742c name="itemprop" value="reviewRating">, #<Nokogiri::XML::Attr:0x3fe0e1087404 name="itemscope">, #<Nokogiri::XML::Attr:0x3fe0e10873dc name="itemtype" value="http://schema.org/Rating">] children=[#<Nokogiri::XML::Text:0x3fe0e108648c "\r\n ">, #<Nokogiri::XML::Element:0x3fe0e108634c name="meta" attributes=[#<Nokogiri::XML::Attr:0x3fe0e108625c name="itemprop" value="worstRating">, #<Nokogiri::XML::Attr:0x3fe0e1086248 name="content" value="1">]>, #<Nokogiri::XML::Element:0x3fe0e10898bc name="meta" attributes=[#<Nokogiri::XML::Attr:0x3fe0e10897cc name="itemprop" value="bestRating">, #<Nokogiri::XML::Attr:0x3fe0e10897b8 name="content" value="5">]>, #<Nokogiri::XML::Element:0x3fe0e1088b10 name="meta" attributes=[#<Nokogiri::XML::Attr:0x3fe0e1088994 name="itemprop" value="ratingValue">, #<Nokogiri::XML::Attr:0x3fe0e1088980 name="content" value="5">]>]>
end
I am interested in this line: <meta itemprop="ratingValue" content="5"> and specifically the vaule of contentwhich in this case is 5.
How do I extract this value?
Edit:
puts reviews.to_html gives this result:
<div class="reviewcontent">
<p class="r-m ">
<span class="s5" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
<meta itemprop="worstRating" content="1">
<meta itemprop="bestRating" content="5">
<meta itemprop="ratingValue" content="5"></span>
</p>
<time datetime="2011-09-15T18:16:10.0000000+02:00" class="ndate strong" title="15. september 2011 - 18:16:10" pubdate>
15. september 2011
<span title="2011-09-15T18:16:10.0000000+02:00"></span>
</time><meta itemprop="dateCreated" content="2011-09-15T18:16:10.0000000+02:00">
<h3 itemprop="headline" class="summary da">
Tip Top
</h3>
<p itemprop="reviewBody">
Bestilte en del fluer, en krogskærper og andre småting.<br>Kom 3 dage efter bestilling og alt var, som det skulle.
</p>
<span class="imagezoom">
</span>
<div class="actions">
<input type="hidden" name="ReviewId" value="4e7240ea00006400020e3b0e"><input type="hidden" name="UserName" value="Strit"><a href="http://www.trustpilot.dk/review/scandicfly.dk/4e7240ea00006400020e3b0e#allcomments" class="comments fb-comments-label" id="FB-comment-box-0">
<span></span>
Kommentar (<comments-count href="http://trustpilot.com/review/scandicfly.dk#4e7240ea00006400020e3b0e">?</comments-count>)
</a>
<a class="useful" data-reviewid="4e7240ea00006400020e3b0e" href="#"><span> </span>
Find nyttig
</a>
<a class="replyAsCompany" href="#"><span></span>
Svar som firma
</a>
<a class="report" data-reviewid="932622" href="#"><span></span>
Rapportér
</a>
</div>
<div class="fb-comments-wrapper">
<div class="social-guidelines">Sociale retningslinjer</div>
</div>
<div class="companyComments" id="CompanyComments_932622">
<div class="companyComments" id="CompanyComments_4e7240ea00006400020e3b0e">
</div>
</div>
</div><div class="reviewcontent">
<p class="r-m ">
<span class="s5" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
<meta itemprop="worstRating" content="1">
<meta itemprop="bestRating" content="5">
<meta itemprop="ratingValue" content="5"></span>
</p>
<time datetime="2011-04-05T16:05:06.0000000+02:00" class="ndate" title="5. april 2011 - 16:05:06" pubdate>
5. april 2011
<span title="2011-04-05T16:05:06.0000000+02:00"></span>
</time><meta itemprop="dateCreated" content="2011-04-05T16:05:06.0000000+02:00">
<h3 itemprop="headline" class="summary da">
en god og flot oplevelse
</h3>
<p itemprop="reviewBody">
Købte en fiskestang hos ScandicFly. Faktra ordrebekræftigelse og det hele præsenteret meget flot. Der kom desuden et notis om min fiskestang var afsendt.<br>Et par dage efter kom min fiskestang med posten forsvarligt pakket ind.
</p>
<span class="imagezoom">
</span>
<div class="actions">
<input type="hidden" name="ReviewId" value="4d9b3db2000064000209035f"><input type="hidden" name="UserName" value="Peter Leter"><a href="http://www.trustpilot.dk/review/scandicfly.dk/4d9b3db2000064000209035f#allcomments" class="comments fb-comments-label" id="FB-comment-box-1">
<span></span>
Kommentar (<comments-count href="http://trustpilot.com/review/scandicfly.dk#4d9b3db2000064000209035f">?</comments-count>)
</a>
<a class="useful" data-reviewid="4d9b3db2000064000209035f" href="#"><span></span>
Find nyttig
</a>
<a class="replyAsCompany" href="#"><span></span>
Svar som firma
</a>
<a class="report" data-reviewid="590687" href="#"><span></span>
Rapportér
</a>
</div>
<div class="fb-comments-wrapper">
<div class="social-guidelines">Sociale retningslinjer</div>
</div>
<div class="companyComments" id="CompanyComments_590687">
<div class="companyComments" id="CompanyComments_4d9b3db2000064000209035f">
</div>
</div>

You can take below xpath after that:
require 'nokogiri'
doc = Nokogiri::HTML::Document.parse <<-_HTML_
<span class="s5" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
<meta itemprop="worstRating" content="1">
<meta itemprop="bestRating" content="5">
<meta itemprop="ratingValue" content="5">
</span>
_HTML_
doc.at("//meta[#itemprop = 'bestRating']/#content").to_s
# => "5"
In your case write as below:
r.at_css(".s1, .s2, .s3, .s4, .s5").at("//meta[#itemprop = 'bestRating']/#content").to_s

Just to clean up Babai's answer a bit, how about:
doc.at('meta[itemprop="bestRating"]')[:content]
Actually you could have just:
rating[:class][/\d/]
See why?

Related

Need to pass filter with URL

Hey can someone please help this is driving me nuts. I need to make a url from the 3 filters 'ecvnd', 'ecdiv', and 'ecclas' and I have values for all 3 plus the base url. I'm stuck and I think this wouldn't be that difficult if my colleague didn't leave me guessing. This is for ecom site so I need the filters to display the proper products in the link.
the values are as such: ECVND=59375, ECDIV=53 and ECCLAS=59
the closest I got was, but not returning the right products.
https://shop.michells.com/orders/catalog/filter_ECVND=59375&filter_ECDIV=53&ECCLAS=59
As you can see from the snippet below, the filters are hidden in the url on click but when you arrive I need the proper filters to display as there are thousands of other products in the system.
ss snippet hint
<!DOCTYPE html>
<!-- saved from url=(0050)http://getbootstrap.com/examples/starter-template/ -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Henry F. Michell's</title>
<link href="/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="/css/michells.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="/js/respond.js"></script>
<script src="/js/html5shiv.min.js"></script>
<![endif]-->
<!--[if lt IE 10]>
<link href="/css/michells.ie.css" media="screen" rel="stylesheet" type="text/css">
<![endif]-->
<!--[if !IE]>
<link href="/css/michells.notie.css" media="screen" rel="stylesheet" type="text/css">
<![endif]-->
<!-- Bootstrap core CSS -->
<link href="//fonts.googleapis.com/css?family=Bree+Serif" media="screen" rel="stylesheet" type="text/css">
<link href="/css/font-awesome.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/css/grid.css" media="screen" rel="stylesheet" type="text/css">
<link href="/css/select2.css" media="(min-width: 768px)" rel="stylesheet" type="text/css">
<link href="/css/select2-bootstrap.css" media="(min-width: 768px)" rel="stylesheet" type="text/css">
<link href="/img/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
</head>
<body>
<div class="subpage hidden-print">
<img src="/img/bg-subpage-banner.jpg">
</div>
<div class="container-fluid">
<!-- HEADER -->
<div class="header">
<!-- green bar across the top -->
<div class="row hidden-print">
<div class="col-xs-12 col-lg-11 lg-right navigationBar">
<!-- contents of the green nav bar -->
<!-- expanded links -->
<ul class="hidden-xs hidden-sm">
<li>Michells.com|</li>
<li>Contact Us|</li>
<li class="hoverMenu">My Account
<ul class="dropdown-menu myaccountMenu left" role="menu">
<li>Change Password</li>
<li>Order History</li>
<li>Customer Statements</li>
<li>Plant Report</li>
</ul>
|</li>
<li>Saved Carts|</li>
<li>Account 1 <a class="small" href="/orders/login/logout">Logout</a></li>
</ul>
<!-- mobile menu -->
<div class="hidden-md hidden-lg right">
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bars"></i>
</button>
<ul class="dropdown-menu pull-right" role="menu">
<li>Michells.com</li>
<li>Contact Us</li>
<li>Change Password</li>
<li>Order History</li>
<li>Customer Statements</li>
<li>Saved Carts</li>
<li>Plant Report</li>
</ul>
</div>
</div>
<!--/mobile menu -->
<!-- /nav bar contents -->
</div>
</div><!-- /green nav bar -->
<img class="logo" src="/img/michells-logo.png">
<div class="mobilelogoutIcon visible-xs hidden-print"><a class="small" href="/orders/login/logout"><i class='fa fa-sign-out'></i></div>
<div class="tabletWelcome hidden-xs hidden-print">
<div>1 <a class="small" href="/orders/login/logout">Logout</a></div>
</div>
<div class="minicart hidden-print">
<a href="/orders/cart/reviewcart">
<i class="fa fa-shopping-cart"></i>
<span class="shoppingCartQty">0</span>
<span class="items"> Items</span>
</a>
</div>
</div>
<!-- / HEADER -->
<!-- Vendors -->
<div class="contents vendorselect">
<h1><span class="hidden-xs"> Online Ordering: </span>Vendors</h1>
<div class="row">
<div class="col-xs-10 col-xs-offset-1 loginform">
<div class="row">
<div class="col-xs-10 col-xs-offset-1">
<form id="run" action="/orders/catalog/filter" method="post">
<p>Please select a vendor to view their products</p>
<select name="filter_ECVND" id="filter_ECVND" class="form-control">
<option>Select Vendor</option>
<option value='940' >Agri Starts (940)</option><option value='1004' >Aldershot (1004)</option><option value='72761' >Aris (72761)</option><option value='26600' >Aris Horticulture Inc (26600)</option><option value='3650' >Athena Brazil (3650)</option><option value='6795' >Blue Heron (6795)</option><option value='9735' >Botany (9735)</option><option value='07600' >Bountiful Farm (07600)</option><option value='9225' >Burchell Nursery (9225)</option><option value='10500' >Cal Seedling (10500)</option><option value='11740' >Casa Flora (11740)</option><option value='921' >Cohen Nurseries (921)</option><option value='14085' >Colony (14085)</option><option value='13688' >CLI (13688)</option><option value='18997' >Dummen (18997)</option><option value='18997' >Dummen Group (18997)</option><option value='18997' >Dummen USA (18997)</option><option value='22470' >Dummen/Fides (22470)</option><option value='19300' >Duwaynes (19300)</option><option value='47200' >Ecke (47200)</option><option value='47200' >Ecke Geraniums, LLC (47200)</option><option value='20100' >Eckert's Greenhouse (20100)</option><option value='20415' >Ekstrom (20415)</option><option value='20710' >Emerald Coast Growers (20710)</option><option value='21320' >Euro American (21320)</option><option value='14085' >F Henny (14085)</option><option value='21901' >Fairy Gardening (21901)</option><option value='22844' >Floral Plant Growers (22844)</option><option value='23720' >Four Star (23720)</option><option value='22702' >Geraniums (22702)</option><option value='26572' >Green Fuse (26572)</option><option value='26473' >Greenheart (26473)</option><option value='26760' >Gro 'N Sell (26760)</option><option value='26750' >Gro Link (26750)</option><option value='26920' >Gulley (26920)</option><option value='26920' >Gulley Greenhouse (26920)</option><option value='35290' >Knox Nursery (35290)</option><option value='35499' >Koba (35499)</option><option value='35500' >Kogut (35500)</option><option value='35700' >Kube Pak (35700)</option><option value='36091' >Lancaster Farms (36091)</option><option value='38030' >Lucas Greenhouses (38030)</option><option value='28480' >Marjama (28480)</option><option value='39345' >Mast Young Plants (39345)</option><option value='40185' >Meadowview (40185)</option><option value='43322' >Morris (43322)</option><option value='43370' >Mountain Creek (43370)</option><option value='46928' >Obersinner (46928)</option><option value='49150' >Pell Greenhouse (49150)</option><option value='51480' >Plainview Growers (51480)</option><option value='51480' >Plainview Growers Inc (51480)</option><option value='51500' >Pleasant View (51500)</option><option value='51555' >Plug Connection (51555)</option><option value='53625' >Reardon (53625)</option><option value='56105' >Russell (56105)</option><option value='57600' >Scott Farms (57600)</option><option value='59375' selected>Silverleaf Greenhouses (59375)</option><option value='59680' >Skagit Gardens (59680)</option><option value='61100' >Spada Nursery (61100)</option><option value='61166' >Speedling Blairsville (61166)</option><option value='61160' >Speedling Inc (61160)</option><option value='61160' >Speedling Inc. (61160)</option><option value='62850' >Sun Gro (62850)</option><option value='32690' >Sunfire (32690)</option><option value='63290' >Swift Greenhouse (63290)</option><option value='22701' >Syngenta (22701)</option><option value='22701' >Syngenta Flowers (22701)</option><option value='22700' >Syngenta Flowers, Inc (22700)</option><option value='51555' >The Plug Connection (51555)</option><option value='66546' >Twin Srpings (66546)</option><option value='68065' >Van Essen (68065)</option><option value='69605' >Wagner Greenhouses Inc (69605)</option><option value='69899' >Walters Gardens (69899)</option><option value='70250' >Welby (70250)</option><option value='72050' >Woodburn Nursery (72050)</option><option value='72055' >Woodburn Nursery (72055)</option> </select>
<div class="btncontainer right">
<button type="submit" class="btn btn-default right">Select</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- / Vendors -->
</div><!-- /.container -->
<div class="footerouter hidden-print">
<div class="footerinner">
<footer class="row">
<div class="col-xs-12 col-lg-4 row center">
<div class="col-xs-12 col-lg-10 col-lg-offset-1 row">
<img src="/img/michells-logo.png" class="footerlogo">
<p class="stayconnected"><em>Stay Connected</em></p>
<div class="col-xs-3"><img src="/img/icon-fb.png"></div>
<div class="col-xs-3"><img src="/img/icon-tw.png"></div>
<div class="col-xs-3"><img src="/img/icon-in.png"></div>
<div class="col-xs-3"><img src="/img/icon-gp.png"></div>
</div>
</div>
<div class="col-xs-12 col-lg-8">
<div class="col-xs-7 col-md-3">
<ul>
<li><strong>Main</strong></li>
<li>Home</li>
<li>About Us</li>
<li>Sales & Service</li>
<li>Michell's Product Catalog</li>
<li>Availability</li>
<li>Contact Us</li>
</ul>
</div>
<div class="col-xs-5 col-md-3">
<ul>
<li><strong>Products</strong></li>
<li>Seeds</li>
<li>Nursery</li>
<li>Plugs </li>
</ul>
</div>
<div class="col-xs-7 col-md-3">
<ul>
<li><strong>Exclusive Partners</strong></li>
<li>Green Fuse</li>
<li>CLI</li>
<li>Fairy Flowers</li>
</ul>
</div>
<div class="col-xs-5 col-md-3">
<ul>
<li><strong>Online Ordering</strong></li>
<li>Shop Now</li>
<li>Login</li>
<li>Register</li>
</ul>
</div>
</div>
<div class="col-xs-12 footerDisc">Pricing subject to change depending upon volume</div>
</footer>
<div class="pagebottom">
<span class="getupdates"><em>Get Updates!</em></span>
<a target="_blank" class="signup" href="http://visitor.r20.constantcontact.com/d.jsp?llr=gpmby6oab&p=oi&m=1115542303206&sit=6diisxiib&f=2dbee31f-253a-4d91-a0f8-4a2206e36974">Sign Up for Email Updates</a><span class="small">Michell's <span class="Labels">2017</span>. All rights Reserved. <span class="bar">|</span> Sitemap<span class="bar">|</span>Terms & Conditions<span class="bar">|</span>Privacy Policy</span>
</div>
</div>
</div>
<div class="device-xs visible-xs hidden-print"></div>
<div class="device-sm visible-sm hidden-print"></div>
<div class="device-md visible-md hidden-print"></div>
<div class="device-lg visible-lg hidden-print"></div>
<div class="device-landscape visible-landscape hidden-print"></div>
<div class="device-portrait visible-portrait hidden-print"></div>
<!-- Bootstrap core JavaScript
================================================== -->
<script type="text/javascript" src="/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/js/select2.js"></script>
<script type="text/javascript" src="/js/hfm.js"></script>
<script type="text/javascript" src="/js/hfm.vendors.js"></script>
<script type="text/javascript">
//<!--
hfm.vendors.init();
//-->
</script>
<script type="text/javascript">
jQuery('.hoverMenu').hover(
function() {
jQuery(this).addClass('open');
}, function() {
jQuery(this).removeClass('open');
}
);
</script>
</body>
</html>
Thank you so much in advance.

display individual item in ng-repeat rendered list

I am trying to display an individual item from the list generating in ng-repeat by clicking on selected item and rendering in a different div. These are the files.
http://plnkr.co/edit/4bnlJnhSHqY1mSPeYOcz?p=preview
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<!-- Standard Meta -->
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<!-- Site Properities -->
<title>Homepage Example - Semantic</title>
<link rel="stylesheet" type="text/css" href="../dist/semantic.css">
<link rel="stylesheet" type="text/css" href="homepage.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script>
<script src="https://cdn.firebase.com/libs/angularfire/1.0.0/angularfire.min.js"></script>
<script src="../dist/semantic.js"></script>
<script src="homepage.js"></script>
<script src="app.js"></script>
</head>
<body id="homebased" ng-controller="MyController">
<div class="ui two divided column padded grid">
<div class="six wide column">
<h2>Six Wide Column</h2>
<form action="ui form">
<div class="two fields">
<div class="field">
<div class="ui action left icon input">
<i class="search icon"></i>
<input type="text" placeholder="Start typing..." ng-model="q">
<div class="ui teal button">
<i class="large arrow right icon"></i></div>
</div>
</div>
<div class="ui hidden divider"></div>
<div class="field">
<label>Filter by..</label>
<div class="ui selection dropdown small">
<input type="hidden" name="name">
<div class="default text">filter</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="name">Author</div>
<div class="item" data-value="year">Year</div>
</div>
</div>
<div name="stp">{{records.indexOf(item)}}</div>
</div>
</form>
</div>
</div>
<div class="ten wide column">
<h2>Search Results</h2>
<div class="ui segment right">
<a class="ui teal left ribbon label">N= {{records.length}}</a>
<div class="ui selection list">
<div class="item" ng-repeat="item in records | filter: q">
<a href="#stp {{records.indexOf(item)}}"><div class="content" >
<div class="header">{{item.name}}</div>
<div class="description">Correspondence begun in: {{item.start}}</div>
</div></a>
</div>
</div>
</div> <!--list-->
</div>
</div>
</body>
</html>
APP.JS
var myApp = angular.module('myApp', ['firebase']);
myApp.controller("MyController", ["$scope", "$firebaseArray", function($scope, $firebaseArray) {
var ref = new Firebase('https://simpleform.firebaseio.com/records');
$scope.records = $firebaseArray(ref);
$scope.recordOrder = 'name';
}]);
I would advise you to dig around ui-router: https://github.com/angular-ui/ui-router
You define views, you define routing then your items access to the other view by using ui-sref="myitem({id: item.id})" and you're all set up!

Using schema.org branchOf with itemref

I have a company page that has all the local branches listed on it.
On the page header, I have an itemType of Organization defined.
Each LocalBusiness (Hotel) is further down the page.
For each Hotel, I'm trying to add the branchOf property using a meta tag, but both Yandex and Google Snippets comes up blank for this attribute. Is it possible to do this way?
<div itemscope itemtype="http://schema.org/Organization" id="schema-organization">
<meta itemprop="description" content="blah blah blah" />
<a href="/" itemprop="url">
<h1 itemprop="name">The Hotel Chain</h1>
</a>
<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<div itemprop="addressLocality">new york city</div>
<meta itemprop="addressRegion" content="NY" />
</div>
</div>
<!-- snip -->
<div itemscope itemtype="http://schema.org/Hotel">
<meta itemprop="branchOf" itemref="schema-organization" />
<h2 itemprop="name">Hotel Location 1</h2>
Get directions on Google Maps
<div itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">
<meta itemprop="latitude" content="40.7450605" />
<meta itemprop="longitude" content="-73.98301879999997" />
</div>
<div class="wrap-address clearfix" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<ul class="ul-reset">
<li><span itemprop="streetAddress">1234 Some Street</span> (between 3rd Ave & Lexington Ave)</li>
<li>
<span itemprop="addressLocality">New York City</span>,
<span itemprop="addressRegion">NY</span>
<span itemprop="postalCode">10016</span>
</li>
</ul>
</div>
<ul>
<li><strong>Phone:</strong><span itemprop="telephone">555-555-5555</span></li>
<li><strong>Fax:</strong><span itemprop="faxNumber">555-555-5555</span></li>
</ul>
<ul>
<li>
Information:
info#hotellocation1.com
</li>
<li itemprop="contactPoint" itemscope itemtype="http://schema.org/ContactPoint">
<span itemprop="contactType">Reservations</span>:
reservations#hotellocation1.com
</li>
<li itemprop="contactPoint" itemscope itemtype="http://schema.org/ContactPoint">
<span itemprop="contactType">Concierge</span>:
Concierge#hotellocation1.com
</li>
</ul>
</div>
About itemref:
it has to be specified on elements with itemscope
it is used to reference other properties (= itemprop in Microdata)
So this means for you:
move itemref to the Hotel
move itemprop="branchOf" to the Organization
Minimal example:
<div itemprop="branchOf" itemscope itemtype="http://schema.org/Organization" id="schema-organization">
<h1 itemprop="name">The Hotel Chain</h1>
</div>
<div itemscope itemtype="http://schema.org/Hotel" itemref="schema-organization">
<h2 itemprop="name">Hotel Location 1</h2>
</div>

Schema.org product title in offer

I'm implementing the Schema.org/Product mark-up in my e-commerce site. However my mark-up is set up in such a way that the itemprop="name" of the product lies inside of the offer (because of the link to the offer). Now to fix this I could use a display:none but that just seems like it is not the best solution. Is there a way to extract the name info about a product out of the offers section or should I change my mark-up?
Cheers,
Adnan
<div itemscope itemtype="http://schema.org/Product">
<img src="imageurl" itemprop="image" />
<h1 class="product_brand" itemprop="brand manufacturer">Brand</h1>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<div class="product_title"><a itemprop="url" href="link"><span itemprop="name">Product name</span></a><span id="stockcount"><link itemprop="availability" href="http://schema.org/InStock">Product Availability</span></link></div>
<div class="product_price" itemprop="price">Price</div>
<link itemprop="itemCondition" href="http://schema.org/NewCondition" />
</div>
<div style="display: none">
<span itemprop="name">Product name (again)</span>
</div>
<div class="description" itemprop="description">
some description
</div>
</div>
You could use a meta tag.
<div itemscope itemtype="http://schema.org/Product">
<img src="imageurl" itemprop="image" />
<h1 class="product_brand" itemprop="brand manufacturer">Brand</h1>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<div class="product_title"><a itemprop="url" href="link"><span itemprop="name">Product name</span></a><span id="stockcount"><link itemprop="availability" href="http://schema.org/InStock">Product Availability</span></link></div>
<div class="product_price" itemprop="price">Price</div>
<link itemprop="itemCondition" href="http://schema.org/NewCondition" />
</div>
<meta itemprop="name" content="Product name" />
<div class="description" itemprop="description">some description</div>
</div>

Warning: Incomplete microdata with schema.org

I take a warning like that: "Warning: Incomplete microdata with schema.org." when Google Structured Data Testing Tool.
<div itemscope itemtype="http://schema.org/Product" style="display: none;">
<img itemprop="image" runat="server" id="listImage" src="" />
<span itemprop="name" runat="server" id="listName"></span>
<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<span itemprop="ratingValue" runat="server" id="rValue"></span>out of <span itemprop="bestRating">5</span> based on
<span itemprop="ratingCount" runat="server" id="allRating"></span>user ratings
</div>
<div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer">
<span itemprop="lowPrice" runat="server" id="lowPrice"></span>to <span itemprop="highPrice" runat="server" id="highPrice"></span>
<meta itemprop="priceCurrency" content="TRY" />
</div>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<a itemprop="url" href="" runat="server" id="firstHotel"></a>
</div>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<a itemprop="url" href="" runat="server" id="secondHotel"></a>
</div>
</div>
what is the problem?
thank u
Google requires certain properties to be present to possibly trigger rich snippets. You ought to check the Google documentation here:
http://support.google.com/webmasters/bin/answer.py?hl=en&answer=146750
I had a same issue with the price value. It needs to have 2 decimal precision.
WRONG:
<meta content="4.5" itemprop="price"></meta>
RIGHT:
<meta content="4.50" itemprop="price"></meta>
Thank u.
I changed
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<a itemprop="url" href="" runat="server" id="firstHotel"></a>
</div>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<a itemprop="url" href="" runat="server" id="secondHotel"></a>
</div>
with
<div>
<a itemprop="url" href="" runat="server" id="firstHotel"></a>
<a itemprop="url" href="" runat="server" id="secondHotel"></a>
</div>

Resources