HTML5之 Microdata微数据
- 为何需要微数据
长篇加累版牍,不好理解
微标记来标注其中内容,让其容易识辨
- RDFa
Resource Description Framework
http://www.w3.org/TR/microdata
http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#microdata
http://www.w3.org/TR/rdfa-in-html
--- itemscope 标记
<articleitemscope>
<span itemprop=musician>张学友</span> steps ontothe stage ...
<span itemprop=musician>刘德华</span> onthe drums ...
<span itemprop=musician>阿宝</span> onthe bass...
<span itemprop=musician>周杰伦</span>onthe piano ...
</article>
这样就将段落中的内容突出出来
--- 搜索引擎如何解析
http://foolip.org/microdatajs/live/ 在线解析
服务器:
{
"items":[{
"properties":{
"musician":["Pat Metheny",
"Antonio Sanchez",
"Steve Rodby",
"Lyle Mays"
}
}}]}
所有的prop都被解析
--- Itemprop支持元素
属性 元素
-------------------------------------------------
src audio,embed,iframe,img,source,video
href a,area,link
datetime time
content meta
data object
--- Itemtype 标记
指定数据格式
<article itemscope itemtype=http://microformats.org/profile/hcalendar#vevent>
<time itemprop=dtstart datetime="2010-10-09T20:30:00-04:00">
Saturday, October 9th 2010, just before half past eight in the evening
</time>
<span itemprop=location>Community Theater</span> in
<span itemprop=location>Morristown, NJ</span>...
<span itemprop=summary>O rchestrion</span> ...
</article>
--- 解析
指定使用日历格式解析数据
BEGIN:VCALENDAR
PRODID:jQuery Microdata
VERSION:2.0
BEGIN:VEVENT
DTSTAMP;VALUE=DATE ‐
TIME:20101227T205755Z
DTSTART;VALUE=DATE ‐
TIME:20101009T2030000400
LOCATION:Community Theater
LOCATION:Morristown\, NJ
SUMMARY:Orchestrion
END:VEVENT
END:VCALENDAR
--- 嵌套使用
<article itemscope itemtype=http://microformats.org/wiki/hreview>
<div itemprop=item itemscope itemtype=http://microformats.org/profile/hcalendar#vevent>
<span itemprop=summary>O rchestrion</span>,
<time itemprop=dtstart datetime="2010-10-09T20:30:00-04:00">October 9th 2010
</time>:
</div>
<span itemprop="summary">A fascinating evening</span>
rated with <span itemprop="rating">5</span> stars out of 5 stars.
<div itemprop=reviewer itemscope itemtype=http://microformats.org/profile/hcard>
<span itemprop=fn>Nicos Thassofilakas</span>,
<a href=http://openweb.cc itemprop=url>openWeb.cc</a>
</div>
</article>
--- ItemId 属性
用于指定唯一序号
<div itemscope itemtype=http://vocab.example.net/book
itemid="urn:isbn:978 ‐0634066634">
<span itemprop=album>One Quiet Night</span> by
<span itemprop=artist>Pat Metheny</span>
(<time itemprop=pubdate datetime=2005‐04‐01>2005</time>,
<span itemprop=pages>88</span> pages)
</div>
--- Itemref 属性
通过使用html标记或者itemid来引用另一个microdata
<article>
<div id=location>
<span itemprop=member>Pat Metheny</span>
</div>
<div id=intro>
<span itemprop=member>Antonio Sanchez</span>
<span itemprop=member>Steve Rodby</span>
<span itemprop=member>Lyle Mays</span>
<span itemprop=band>Pat Metheny Group</span>
</div>
</article>
<div itemscope itemref ="location intro"></div>
--- 解析可用字典
http://micoformats.org
- Microdata DOM API
JS完全支持
var allNodes = document.getItems();
var vCards = document.getItems('http://microfomats.org/profile/hcard');
属性 内容
------------------------------------------
itemScope Value of itemscope attribute
itemType Value of itemtype attribute, if present
itemId Value of itemid attribute, if present
itemRef Value of itemref attribute, if present
- 属性方法一览
属性/方法 内容
------------------------------------
length 集合中元素对象
item(index) 访问元素内容
namedItem(name) 使用itemprop中的name属性来访问对象
namedItem(name).values 访问itemprop指定的name中的属性的值
Names DOMStringList所有itemprop的属性值
names.length Itemprop值得长度
names.item(index) 使用itemprop属性值的对象值
names.contains(name) 判断是否包含itemprop属性
--- 小实例
<section itemscope itemtype="http://www.data-vocabulary.org/Person/">
<h1 itemprop="name">张三</h1>
<p><img src="1.jpg" alt="张三照片" itemprop="photo"></p>
<p><a href="www.zhangsan.org" itemprop="url">张三哥</a></p>
<dd itemprop="address" itemscope itemtype="http://www.data-vocabulary.org/Person/">
<span itmeprop="region">东城区</span>
</dd>
</section>
HTML5之 Microdata微数据的更多相关文章
- HTML5扩展之微数据与丰富网页摘要itemscope, itemtype, itemprop
HTML5扩展之微数据与丰富网页摘要 by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpr ...
- HTML5扩展之微数据与丰富网页摘要
一.微数据是? 一个页面的内容,例如人物.事件或评论不仅要给用户看,还要让机器可识别.而目前机器智能程度有限,要让其知会特定内容含义,我们需要使用规定的标签.属性名以及特定用法等.举个简单例子,我们使 ...
- HTML5扩展之微数据与丰富网页摘要——张鑫旭
一.微数据是? 一个页面的内容,例如人物.事件或评论不仅要给用户看,还要让机器可识别.而目前机器智能程度有限,要让其知会特定内容含义,我们需要使用规定的标签.属性名以及特定用法等.举个简单例子,我们使 ...
- HTML5微数据
本篇文章是一个纯搬运贴,原博主是在是做的太详细了 原贴地址:http://www.zhangxinxu.com/wordpress/2011/12/html5扩展-微数据-丰富网页摘要/ 一.微数据是 ...
- HTML5可视化编辑与微数据
1.HTML 5 全局 contenteditable 属性 contenteditable 属性规定是否可编辑元素的内容. <p contenteditable="true" ...
- seo之google rich-snippets丰富网页摘要结构化数据(微数据)实例代码
seo之google rich-snippets丰富网页摘要结构化数据(微数据)实例代码 网页摘要是搜索引擎搜索结果下的几行字,用户能通过网页摘要迅速了解到网页的大概内容,传统的摘要是纯文字摘要,而结 ...
- HTML5在客户端存储数据的新方法——localStorage
HTML5在客户端存储数据的新方法--localStorage localStorage作为HTML5本地存储web storage特性的API之一,主要作用是将数据保存在客户端中,而客户端一般是指上 ...
- HTML5线性图表 图表数据区域可着色
这是一款基于Canvas的HTML5图表应用,在图表数据初始化的时候伴随动画效果. 在线演示: 点击演示 源代码下载: 点击下载 核心jQuery代码: var myData = { labels ...
- HTML5深入学习之数据存储
概述 本来,数据存储都是由 cookie 完成的,但是 cookie 不适合大量数据的存储,cookie 速度慢且效率低. 现在,HMLT5提供了两种在客户端存储数据的办法: localStorage ...
随机推荐
- C++之EOF()
fstream流的eof()推断有点不合常理 按常理逻辑来说,假设到了文件末尾的话,eof()应该返回真,可是,C++输入输出流怎样知道是否到末尾了呢? 原来依据的是:假设fin>>不能再 ...
- xampp
Fatal error: Class 'kernel' not found in C:\xampp\htdocs\shopex\install\install.core.php on line 10 ...
- Mac下使用Fiddler
Fiddler是用C#开发的. 所以Fiddler不能在Mac系统中运行. 没办法直接用Fiddler来截获MAC系统中的HTTP/HTTPS, Mac 用户怎么办呢? Fiddler可以允 ...
- cocos2dx-3.2 环境配置
一.软件 1)VS2012(C++11特性在VS2012以上可以使用) 2)Cocos2d-x官网源码 3)JDK 4)NDK(3.2要用r9d版本,用了android-ndk-r8e报错了) 5)A ...
- graylog2 架构--转载
原文地址:http://docs.graylog.org/en/latest/pages/architecture.html Architectural considerations There ar ...
- 源码分析shiro认证授权流程
1. shiro介绍 Apache Shiro是一个强大易用的Java安全框架,提供了认证.授权.加密和会话管理等功能: 认证 - 用户身份识别,常被称为用户“登录”: 授权 - 访问控制: 密码加密 ...
- Linux shell 脚本攻略之创建不可修改文件
摘自:<Linux shell 脚本攻略>
- 小白日记42:kali渗透测试之Web渗透-SQL盲注
SQL盲注 [SQL注入介绍] SQL盲注:不显示数据库内建的报错信息[内建的报错信息帮助开发人员发现和修复问题],但由于报错信息中提供了关于系统的大量有用信息.当程序员隐藏了数据库内建报错信息,替换 ...
- 小白日记33:kali渗透测试之Web渗透-扫描工具-Burpsuite(一)
扫描工具-Burpsuite Burp Suite是Web应用程序测试的最佳工具之一,成为web安全工具中的瑞士军刀.其多种功能可以帮我们执行各种任务.请求的拦截和修改,扫描web应用程序漏洞,以暴力 ...
- python 调用zabbix api接口实现主机的增删改查
python程序调用zabbix系统的api接口实现对zabbix_server端主机的增删改查,使用相关功能时候,需要打开脚本中的相关函数. 函数说明: zabbixtools() 调用zabbi ...