【问题】
别人遇到的问题:
用wordpress importer导入dedecms的生成的WXR(xml)文件,结果出错。
刚上来提示没有
<wp:wxr_version>1.2</wp:wxr_version>
于是加上这个后。
导入出现:
Import WordPress Failed to import author . Their posts will be attributed to the current user. |
和:
Import WordPress Failed to import author . Their posts will be attributed to the current user. Failed to import “”: Invalid post type |
【解决过程】
1.参考了:
【已解决】使用wordpress importer导入WXR时出错:Failed to create new user for XXX. asign to the current user
未解决问题。
2.又参考了:
【已解决】WordPress Importer导入xml文件时,无法识别导入的作者Author
“您说是错误ASCII控制字符。我发现我文章没那些控制符。”
3.参考:
中提到的,关于WXR的格式的介绍:
WordPress eXtended Rss (WXR)文件格式解析
其中,有完整的WXR格式的介绍。
然后自己去添加相关的wxr的tag,至少应该包括:
<wp:wxr_version> <wp:author> |
如果还不行,再继续一个个,把其余的wxr的头都加上,比如:
<wp:base_site_url> <wp:base_blog_url> |
等等,结果是:
您好文章标题ok了。但是分类无法导入。
4.这是我代码。还是不行。感觉还是分类目录的问题:
<?xml version="1.0" encoding="gb2312" ?> <rss version="2.0" xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/1.2/" > <channel> <title>章丘新闻网-章丘唯一的新闻资讯平台</title> <link>http://www.diaosinanshi2.com </link> <description>章丘新闻网-章丘市的唯一新闻门户,章丘新闻网集章丘新闻,济南新闻,国内新闻,国际新闻于一网的大型新闻资讯平台。</description> <language>zh-CN</language> <wp:wxr_version>1.2</wp:wxr_version> <generator>章丘新闻网-章丘唯一的新闻资讯平台</generator> <webmaster>[email protected]</webmaster> <wp:category><wp:term_id>1</wp:term_id><wp:category_nicename> 章丘新闻</wp:category_nicename><wp:category_parent>< /wp:category_parent><wp:cat_name>< ![CDATA[章丘新闻]]></wp:cat_name></wp:category> <item> <link>http://www.diaosinanshi2.com /guoji/805.html</link> <title><![CDATA[窃听门:美国和德国狼狈为奸]]></title> <author>admin</author> <category domain="category">< ![CDATA[章丘新闻]]></category> <wp:post_type>post</wp:post_type> <pubDate>Mon, 08 Jul 2013 12:13:26 +0800</pubDate> <guid>http://www.diaosinanshi2.com /guoji/805.html</guid> <description><! [CDATA[据 德国 《明镜》周刊报道, 美国 安全局和 德国 情报局的 合作 远比人们知晓的要密切。美方向德方 提供 了分析工具,以便德方监视流经德国的 外国 数据 流。 美国 前情报人员 斯诺登 在一个 采访 中表示,美国不但和德国,而且和大部分西方国家狼狈为奸,共 ... <br /><b>文章分类</b>:国际新闻<br /><a href="/guoji/805.html" target="_blank">阅读全文</a> | <a href="/guoji/805.html" target="_blank">评论回复</a>]]></description> </item> <item> <link>http://www.diaosinanshi2.com /guonei/difang/804.html</link> <title><![CDATA[英大赞:香港一国两制运作良好]]></title> <author>admin</author> <category domain="category">< ![CDATA[章丘新闻]]></category> <wp:post_type>post</wp:post_type> <pubDate>Mon, 08 Jul 2013 12:12:17 +0800</pubDate> <guid>http://www.diaosinanshi2.com /guonei/difang/804.html</guid> <description><! [CDATA[据报道,国际社会对 香港 的 自由 度评价不俗,当中 英国 政府便曾在提交国会的 报告 中,形容 香港 继续 享有新闻 自由 ,而且法治与司法独立,仍然是香港社会维持安定繁荣的基石,认为《中英联合声明》所 承诺 的权利及自由得到尊重。 英国政府在今年便曾 ... <br /><b>文章分类</b>:地方新闻<br /><a href="/guonei/difang/804.html" target="_blank">阅读全文</a> | <a href="/guonei/difang/804.html" target="_blank">评论回复</a>]]></description> </item> </channel> </rss>
然后去参考:
WordPress eXtended Rss (WXR)文件格式解析
做如下事情:
(1)
“<?xml version="1.0" encoding="gb2312" ?>”
确保你的文件本身的确是gb2312
(2)
<wp:category_nicename>章丘新闻</wp:category_nicename>
应该不对。
因为wordpress内部,只支持:
英文名
如果是中文,一般做法是,给其编码encode变成,类似于这种:
<wp:category><wp:category_nicename> %ef%bc%90%ef%bc%91%ef%bc%8e%e3%81%af%e3%81%98%e3%82%81%e3%81 %ab</wp:category_nicename><wp:category_parent>< /wp:category_parent><wp:cat_name><![CDATA[第一章 初めに]]></wp:cat_name></wp:category>
(摘自:https://github.com/komagata/daitoua-sensou-jyuugunki/blob/master/daitoua-sensou-jyuugunki.xml)
最终,解决了问题。
【总结】
其实这类问题很简单,要先去搞懂wxr的格式,再去照葫芦画瓢,添加对应的,必须的那些tag,即可。
转载请注明:在路上 » 【已解决】wordpress importer导入WXR时出错:Import WordPress,Failed to import author.Their posts will be attributed to the current user.