Created
December 6, 2012 01:42
-
-
Save karlcow/4221190 to your computer and use it in GitHub Desktop.
experiment of accessing Microdata in an html page with microdata API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Microdata and Geolocation</title> | |
</head> | |
<body> | |
<ul> | |
<li itemscope itemtype="http://schema.org/Place"> | |
<span itemprop="name">Tsujido</span> | |
<div itemprop="geo" | |
itemscope | |
itemtype="http://schema.org/GeoCoordinates"> | |
<meta itemprop="latitude" content="35.336833"/> | |
<meta itemprop="longitude" content="139.447083"/> | |
</div> | |
</li> | |
<li itemscope itemtype="http://schema.org/Place"> | |
<span itemprop="name">Meguro</span> | |
<div itemprop="geo" | |
itemscope | |
itemtype="http://schema.org/GeoCoordinates"> | |
<meta itemprop="latitude" content="35.633983"/> | |
<meta itemprop="longitude" content="139.71600"/> | |
</div> | |
</li> | |
</ul> | |
<script> | |
var places = document.getItems('http://schema.org/Place'); | |
console.log(places); | |
for (var i = places.length - 1; i >= 0; i--) { | |
longitude = places[i].properties['geo'][0].properties['longitude'][0].itemValue; | |
console.log(longitude); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One issue is that there is no JavaScript API for accessing RDFa Lite data. Maybe a shim on top of microdata API could do the job?