这是一个Atom 1.0的示例:
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text">dive into mark</title>
<updated>2005-07-10T12:29:29Z</updated>
<id>tag:example.org,2003:3</id>
<link rel="alternate" type="text/html" hreflang="en" href="http://example.org/"/>
<entry>
<title>Atom draft-07 snapshot</title>
<link rel="alternate" type="text/html"
href="http://example.org/2005/04/02/atom"/>
<id>tag:example.org,2003:3.2397</id>
<updated>2005-07-10T12:29:29Z</updated>
<published>2003-12-13T08:29:29-04:00</published>
<author>
<name>Mark Pilgrim</name>
<uri>http://example.org/</uri>
<email>f8dy@example.com</email>
</author>
<summary>Some text.</summary>
<content type="html">
Some text
</content>
</entry>
</feed>
Atom中并没有定义tag元素及评论部分的元素,要完整了备份Blog的信息,就要对Atom 1.0进行扩展。在Blog日志中有两个元素比较重要,就是tag和comment。tag标签很简单,只包含text。comment标签就要定义为复合标签了,其中包为含4个子元素author,title,content,published。这样所定义的格式就能很好的保存Blog的数据信息了。
下面是加工后的Blog通用数据备份格式:
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text">dive into mark</title>
<updated>2005-07-10T12:29:29Z</updated>
<id>tag:example.org,2003:3</id>
<link rel="alternate" type="text/html" hreflang="en" href="http://example.org/"/>
<entry>
<title>标题</title>
<link rel="alternate" type="text/html"
href="http://example.org/2005/04/02/atom"/>
<id>tag:example.org,2003:3.2397</id>
<updated>2005-07-10T12:29:29Z</updated>
<published>2003-12-13T08:29:29-04:00</published>
<author>
<name>作者名称</name>
<uri>http://example.org/</uri>
<email>f8dy@example.com</email>
</author>
<summary>摘要</summary>
<content type="html">
正文
</content>
<tag>第一个tag</tag>
<tag>第二个tag</tag>
<tag>第三个tag等等</tag>
<comment>
<author>
<name>评论人</name>
<uri>网站</uri>
<email>邮箱</email>
</author>
<content>评论内容</content>
<published>评论时间</published>
</comment>
<trackback>
<title type="html">引用的标明</title>
<published>引用的时间</published>
<content type="html">引用的内容</content>
<link rel="alternate" type="text/html" href="引用链接"/>
</trackback>
</entry>
</feed>
目前Z-Blog 1.3 Beta4已经可以支持Blog通用数据备份格式,并实现了数据导出备份功能。
文字内容备份各种方法应该都行,关键是图片备份会比较麻烦。如果导入导出能够把图片问题解决了那就好用了。
备份图片是一个麻烦的事情,不适合用XML保存,最好还是存在数据库中。
不过能够制定一个通用的备份标准,比较有利于BLOG的内容的迁移。