<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Shane.Hu&#039;s Blog &#187; IT水手</title>
	<atom:link href="http://huxuan.org/category/it%e6%b0%b4%e6%89%8b/feed/" rel="self" type="application/rss+xml" />
	<link>http://huxuan.org</link>
	<description>Sharing of Computer Geek, Recording of College Time &#38; Thinking of Daily Life</description>
	<lastBuildDate>Tue, 17 Jan 2012 06:27:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>虾米自动签到的python脚本</title>
		<link>http://huxuan.org/20111212/a-python-script-implement-xiami-auto-checkin/</link>
		<comments>http://huxuan.org/20111212/a-python-script-implement-xiami-auto-checkin/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 16:56:20 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[xiami_auto_checkin]]></category>

		<guid isPermaLink="false">http://huxuan.org/?p=1095</guid>
		<description><![CDATA[一个练手的小脚本，暂时只是实现了签到，还没有很完备的错误处理，而且在实现“全自动签到”上还没有想出什么合理的方案，先把代码贴上现丑了…… 使用方法很简单 python xiami_auto_checkin.py email password 即把用户名（email）和密码作为参数传进去即可 如果你只是签固定的一个帐号，也可以直接将代码中的读参数改成赋值 这个代码只是最初的版本，你可以在这里看到最新的进展 #!/usr/bin/python # encoding:utf-8 import re import sys import urllib import urllib2 import cookielib def check(response): &#34;&#34;&#34; docstring for check &#34;&#34;&#34; pattern = re.compile(r&#039;&#60;div class=&#34;idh&#34;&#62;(已连续签到\d+天)&#60;/div&#62;&#039;) result = pattern.search(response) if result: return result.group(1) &#8230; <a href="http://huxuan.org/20111212/a-python-script-implement-xiami-auto-checkin/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>一个练手的小脚本，暂时只是实现了签到，还没有很完备的错误处理，而且在实现“全自动签到”上还没有想出什么合理的方案，先把代码贴上现丑了……</p>
<p>使用方法很简单 </p>
<pre>
python xiami_auto_checkin.py email password
</pre>
<p>即把用户名（email）和密码作为参数传进去即可<br />
如果你只是签固定的一个帐号，也可以直接将代码中的读参数改成赋值</p>
<p>这个代码只是最初的版本，你可以在<a href="http://huxuan.org/projects/xiami_auto_checkin/" title="xiami_auto_checkin">这里</a>看到最新的进展</p>
<pre>
#!/usr/bin/python
# encoding:utf-8

import re
import sys
import urllib
import urllib2
import cookielib

def check(response):
    &quot;&quot;&quot;
    docstring for check
    &quot;&quot;&quot;
    pattern = re.compile(r&#039;&lt;div class=&quot;idh&quot;&gt;(已连续签到\d+天)&lt;/div&gt;&#039;)
    result = pattern.search(response)
    if result: return result.group(1)
    return False
    pass

def main():
    &quot;&quot;&quot;
    docstring for main
    &quot;&quot;&quot;

    # Get email and password
    if len(sys.argv) != 3:
        print &#039;[Error] Please input email &amp; password as sys.argv!&#039;
        return
    email = sys.argv[1]
    password = sys.argv[2]

    # Init
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
    urllib2.install_opener(opener)

    # Login
    login_url = &#039;http://www.xiami.com/web/login&#039;
    login_data = urllib.urlencode({&#039;email&#039;:email, &#039;password&#039;:password, &#039;LoginButton&#039;:&#039;登陆&#039;,})
    login_headers = {&#039;Referer&#039;:&#039;http://www.xiami.com/web/login&#039;, &#039;User-Agent&#039;:&#039;Opera/9.60&#039;,}
    login_request = urllib2.Request(login_url, login_data, login_headers)
    login_response = urllib2.urlopen(login_request).read()

    # Checkin
    checkin_pattern = re.compile(r&#039;&lt;a class=&quot;check_in&quot; href=&quot;(.*?)&quot;&gt;&#039;)
    checkin_result = checkin_pattern.search(login_response)
    if not checkin_result:
        # Checkin Already | Login Failed
        result = check(login_response)
        if result :
            print &#039;[Succeed] Checkin Already!&#039;, email, result
        else:
            print &#039;[Error] Login Failed!&#039;
        return
    checkin_url = &#039;http://www.xiami.com&#039; + checkin_result.group(1)
    checkin_headers = {&#039;Referer&#039;:&#039;http://www.xiami.com/web&#039;, &#039;User-Agent&#039;:&#039;Opera/9.60&#039;,}
    checkin_request = urllib2.Request(checkin_url, None, checkin_headers)
    checkin_response = urllib2.urlopen(checkin_request).read()

    # Result
    result = check(checkin_response)
    if result:
        print &#039;[Succeed] Checkin Succeed!&#039;, email, result
    else:
        print &#039;[Error] Checkin Failed!&#039;
    pass

if __name__==&#039;__main__&#039;:
    main()
</pre>
<p></a></p>
<p>有任何问题，欢迎批评指正，更多更新信息，请参见<a href="http://huxuan.org/projects/xiami_auto_checkin/">这里</a></p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20111212/a-python-script-implement-xiami-auto-checkin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>用Python处理xml文件中的非法字符</title>
		<link>http://huxuan.org/20111013/handle-xml-file-with-invalid-character-via-python/</link>
		<comments>http://huxuan.org/20111013/handle-xml-file-with-invalid-character-via-python/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 11:05:19 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[pyth]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://huxuan.org/?p=1093</guid>
		<description><![CDATA[用xml.dom.minidom.parse()解析xml文件时遇到非法字符直接报错的问题 最后的方案是把纯文本方式读入文件，然后用字符串来处理 可以得到将非法字符全部剔除的结果 #!/usr/bin/python # -*- coding:utf-8 -*- import string import xml.dom.minidom def parse_xml(file_path): """ Handle xml file with invalid character [input] : path of the xml file [output] : xml.dom.minidom.Document instance """ try: xmldoc = xml.dom.minidom.parse(file_path) except: f = &#8230; <a href="http://huxuan.org/20111013/handle-xml-file-with-invalid-character-via-python/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>用xml.dom.minidom.parse()解析xml文件时遇到非法字符直接报错的问题<br />
最后的方案是把纯文本方式读入文件，然后用字符串来处理<br />
可以得到将非法字符全部剔除的结果</p>
<pre>
#!/usr/bin/python
# -*- coding:utf-8 -*-

import string
import xml.dom.minidom

def parse_xml(file_path):
    """
    Handle xml file with invalid character
    [input] : path of the xml file
    [output] : xml.dom.minidom.Document instance
    """
    try:
        xmldoc = xml.dom.minidom.parse(file_path)
    except:
        f = file(file_path)
        s = f.read()
        f.close()

        ss = s.translate(None, string.printable)
        s = s.translate(None, ss)

        xmldoc = xml.dom.minidom.parseString(s)
    return xmldoc

if __name__ == '__main__':
    pass
</pre>
<p>P.S. 如果有更好的解决方案，欢迎交流</p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20111013/handle-xml-file-with-invalid-character-via-python/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>在Eclipse中运行pdfbox</title>
		<link>http://huxuan.org/20110722/run-pdfbox-in-eclipse/</link>
		<comments>http://huxuan.org/20110722/run-pdfbox-in-eclipse/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 09:27:56 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[ICST]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[pdfbox]]></category>

		<guid isPermaLink="false">http://huxuan.org/?p=1083</guid>
		<description><![CDATA[【前言】pdfbox是实验室做文档识别需要了解的开源项目，可是官网doc过于简略，网上资料很多只是调用jar并非在Eclipse中配置运行源代码，仅以此文祭奠我两天的折腾时间…… 0) Environment Specification OS:Windows 7 IDE:Eclipse SDK 3.7.0 JDK:Version 6 Update 26 1) This post will not involve the configuration of Java, but you need to confirm JAVA_HOME is in your &#8220;Environment Variable&#8221; which we will need later on. &#8230; <a href="http://huxuan.org/20110722/run-pdfbox-in-eclipse/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>【前言】pdfbox是实验室做文档识别需要了解的开源项目，可是官网doc过于简略，网上资料很多只是调用jar并非在Eclipse中配置运行源代码，仅以此文祭奠我两天的折腾时间……</p>
<p>0) Environment Specification<br />
OS:Windows 7<br />
IDE:Eclipse SDK 3.7.0<br />
JDK:Version 6 Update 26</p>
<p>1) This post will not involve the configuration of Java, but you need to confirm JAVA_HOME is in your &#8220;<a href="http://en.wikipedia.org/wiki/Environment_variable">Environment Variable</a>&#8221; which we will need later on.<br />
The key should be &#8220;JAVA_HOME&#8221; and the value is the path of JDK, for me is &#8220;D:\Program Files\Java\jdk1.6.0_26&#8243;</p>
<p>2) Download and extract pdfbox, pdfbox-*.*.*-src.zip, for me is &#8220;pdfbox-1.6.0-src.zip&#8221; and the extact location is &#8220;E:\Code\JAVA\pdfbox-1.6.0&#8243;<br />
<a href="http://pdfbox.apache.org/download.html">http://pdfbox.apache.org/download.html</a></p>
<p>3) Download and Extract Maven2, apache-maven-*.*.*-bin.zip, for me is &#8220;apache-maven-3.0.3-bin.zip&#8221; and the extract location is &#8220;D:\Program Files\apache-maven-3.0.3&#8243;<br />
<a href="http://maven.apache.org/download.html">http://maven.apache.org/download.html</a></p>
<p>4) Configure the &#8220;Environment Variable&#8221; for Maven2 / Install Maven2<br />
4.1) Add key &#8220;M2_HOME&#8221; and the value is path you extact Maven2, for me is &#8220;D:\Program iles\apache-maven-3.0.3&#8243;<br />
4.2) Add &#8220;%M2_HOME%\bin&#8221; to the key &#8220;Path&#8221;.<br />
4.3) Open a new command prompt and run &#8220;mvn &#8211;version&#8221; to verify correct installation.</p>
<p>5) Install and configure the pdfbox via Maven2<br />
5.1) Open a new command prompt and change directory to the extract location of pdfbox<br />
5.2) Run &#8220;mvn clean install&#8221; to install the pdfbox<br />
5.3) Run &#8220;mvn eclipse:eclipse&#8221; to make it a eclipse project.<br />
5.4) Run &#8220;mvn -Declipse.workspace=&#8221;PATH OF THE WORKSPACE&#8221; eclipse:configure-workspace&#8221; to add M2_REPO classpath variable to Eclipse.<br />
Note : 5.3 &#038; 5.4 is the MOST IMPORTANT part.</p>
<p>6) Import the project into Eclipse with the root directory of pdfbox (for me is E:\Code\JAVA\pdfbox-1.6.0) then there should be no errors in all the projects.</p>
<p>7) Edit the &#8220;Run Configurations&#8221; and enter the command line arguments in the &#8220;Arguments&#8221; tab and then everything should run correctly.</p>
<p>Reference:<br />
1) <a href="http://pdfbox.apache.org/userguide/building_pdfbox.html">http://pdfbox.apache.org/userguide/building_pdfbox.html</a><br />
2) <a href="http://maven.apache.org/download.html#Installation">http://maven.apache.org/download.html#Installation</a><br />
3) <a href="http://maven.apache.org/guides/getting-started/index.html">http://maven.apache.org/guides/getting-started/index.html</a><br />
4) <a href="http://www.mkyong.com/maven/how-to-configure-m2_repo-variable-in-eclipse-ide/">http://www.mkyong.com/maven/how-to-configure-m2_repo-variable-in-eclipse-ide/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20110722/run-pdfbox-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>利用Python解析新浪博客javascript生成的评论</title>
		<link>http://huxuan.org/20110708/using-python-to-decode-the-sina-blog-s-comments-generated-by-javascript/</link>
		<comments>http://huxuan.org/20110708/using-python-to-decode-the-sina-blog-s-comments-generated-by-javascript/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 02:21:04 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Sina2WordPress]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://huxuan.org/?p=1060</guid>
		<description><![CDATA[【前言】sina2wordpress终于有一个大概模样了，目前版本号为0.1 这是本站项目地址，这是代码托管地址 言归正传，目前新浪博客的评论是用JavaScript生成的，直接用urllib2读取的信息中没有评论信息 通过Firefox下的firebug或者Chrome自带的Develop Tools，都可以找到js脚本在运行时GET的数据，具体方法是：打开之后选择“Network”标签，并选择“XHR”分类项，刷新页面并等待加载完成，稍等一会就会看到GET了一条以“comment”开头的html页面。 主要规律是，例如韩寒同学的这篇日志地址是 “http://blog.sina.com.cn/s/blog_4701280b0101854o.html”，那么打开日志页面时GET的就会是 &#8220;comment_4701280b0101854o_1.html&#8221;，规律不难发现，后面的那个数字就是评论的页数，最后的那个页数可以变为任意整数（没有尝试过上限），当超过实际评论页数时，显示的会是同样的编码，这也就是循环结束条件 此地址为相对路径，打开后是一堆乱码，这就是JavaScript的数据存储形式——json编码。可以简单的类比成Python中的字典，本例中共有两个关键字，一个是“Code”，对应值&#8221;A00006&#8243;，没发现啥用处，第二个关键字是“data”，其余部分均为data的对应值，利用Python的json模块进行解析可以发现，这就是评论的html代码。不过这里需要注意的是，第二个关键字“data”缺少双引号，直接解析会报错，需要先进行字符串处理，然后再解析。 相关代码如下（完整代码可以参见前言中的代码托管地址）： #根据json解析之后的html代码总结出来的各个关键信息的正则表达式 comment_author_pattern=re.compile(r&#039;&#60;span class=&#34;SG_revert_Tit&#34;.*?&#62;(.*?)&#60;/span&#62;&#039;) comment_url_pattern=re.compile(r&#039;&#60;a href=&#34;(.*?)&#34; target=&#34;_blank&#34;&#62;(.*?)&#60;/a&#62;&#039;) comment_time_pattern=re.compile(r&#039;&#60;em class=&#34;SG_txtc&#34;&#62;(.*?)&#60;/em&#62;&#039;) comment_content_pattern=re.compile(r&#039;&#60;div class=&#34;SG_revert_Inner SG_txtb&#34;.*?&#62;(.*?)&#60;/div&#62;&#039;, re.S) #这里的re.S很重要 def commentsAnalyze(key): #key为地址中间的标识性字符串 num=1 #表示评论的页数 url=r&#039;http://blog.sina.com.cn/s/comment_%s_%d.html&#039; %(key, num) #生成json编码对应的地址 page=urllib2.urlopen(url).read().replace(&#039;data:&#039;,&#039;\&#34;data\&#34;:&#039;,1) #给data添加双引号 while not &#039;noCommdate&#039; in page: #noCommdata是无评论json编码页面的关键字 &#8230; <a href="http://huxuan.org/20110708/using-python-to-decode-the-sina-blog-s-comments-generated-by-javascript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>【前言】sina2wordpress终于有一个大概模样了，目前版本号为0.1<br />
<a href="http://huxuan.org/projects/sina2wordpress/" title="Sina2WordPress">这是本站项目地址</a>，<a href="https://github.com/huxuan/sina2wordpress">这是代码托管地址</a></p>
<p>言归正传，目前新浪博客的评论是用JavaScript生成的，直接用urllib2读取的信息中没有评论信息</p>
<p>通过Firefox下的firebug或者Chrome自带的Develop Tools，都可以找到js脚本在运行时GET的数据，具体方法是：打开之后选择“Network”标签，并选择“XHR”分类项，刷新页面并等待加载完成，稍等一会就会看到GET了一条以“comment”开头的html页面。</p>
<p>主要规律是，例如韩寒同学的这篇日志地址是 “http://blog.sina.com.cn/s/blog_4701280b0101854o.html”，那么打开日志页面时GET的就会是 &#8220;comment_4701280b0101854o_1.html&#8221;，规律不难发现，后面的那个数字就是评论的页数，最后的那个页数可以变为任意整数（没有尝试过上限），当超过实际评论页数时，显示的会是同样的编码，这也就是循环结束条件</p>
<p>此地址为相对路径，打开后是一堆乱码，这就是JavaScript的数据存储形式——json编码。可以简单的类比成Python中的字典，本例中共有两个关键字，一个是“Code”，对应值&#8221;A00006&#8243;，没发现啥用处，第二个关键字是“data”，其余部分均为data的对应值，利用Python的json模块进行解析可以发现，这就是评论的html代码。不过这里需要注意的是，第二个关键字“data”缺少双引号，直接解析会报错，需要先进行字符串处理，然后再解析。</p>
<p>相关代码如下（完整代码可以参见前言中的代码托管地址）：</p>
<pre>
#根据json解析之后的html代码总结出来的各个关键信息的正则表达式
comment_author_pattern=re.compile(r&#039;&lt;span class=&quot;SG_revert_Tit&quot;.*?&gt;(.*?)&lt;/span&gt;&#039;)
comment_url_pattern=re.compile(r&#039;&lt;a href=&quot;(.*?)&quot; target=&quot;_blank&quot;&gt;(.*?)&lt;/a&gt;&#039;)
comment_time_pattern=re.compile(r&#039;&lt;em class=&quot;SG_txtc&quot;&gt;(.*?)&lt;/em&gt;&#039;)
comment_content_pattern=re.compile(r&#039;&lt;div class=&quot;SG_revert_Inner SG_txtb&quot;.*?&gt;(.*?)&lt;/div&gt;&#039;, re.S) #这里的re.S很重要

def commentsAnalyze(key): #key为地址中间的标识性字符串
    num=1 #表示评论的页数
    url=r&#039;http://blog.sina.com.cn/s/comment_%s_%d.html&#039; %(key, num) #生成json编码对应的地址
    page=urllib2.urlopen(url).read().replace(&#039;data:&#039;,&#039;\&quot;data\&quot;:&#039;,1) #给data添加双引号
    while not &#039;noCommdate&#039; in page: #noCommdata是无评论json编码页面的关键字
        data=json.loads(page)[&#039;data&#039;] #&lt;strong&gt;最关键的一部&lt;/strong&gt;，json代码的解析并有效部分

        #通过正则匹配出相关信息，其中url是可能存在的，将稍后处理
        author=comment_author_pattern.findall(data)
        url=[]
        time=comment_time_pattern.findall(data)
        content=comment_content_pattern.findall(data)

        #后处理url，判断前面提取出来的author周边是不是带有&lt;a&gt;标签（超链接）即可
        for i in range(len(author)):
            comment_id+=1
            result=comment_url_pattern.search(author[i])
            if result:
                url.append(result.group(1))
                author[i]=result.group(2)
            else: url.append(&#039;&#039;)

        num+=1 #评论页数+1
        url=r&#039;http://blog.sina.com.cn/s/comment_&#039;+key+&#039;_&#039;+str(num)+&#039;.html&#039; #生成新的页面地址
        page=urllib2.urlopen(url).read().replace(&#039;data:&#039;,&#039;\&quot;data\&quot;:&#039;,1) #修正data的双引号，重复循环
</pre>
<p></a></p>
<p>【后记】感谢 <a href="http://twitter.com/lqs">@lqs</a> 学长和 <a href="http://code.google.com/p/bhosc/">北航开源俱乐部BHOSC的同胞们</a> 在此问题上给予的帮助</p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20110708/using-python-to-decode-the-sina-blog-s-comments-generated-by-javascript/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>精简WordPress eXtended Rss (WXR) 文件格式</title>
		<link>http://huxuan.org/20110624/simplify-wordpress-extended-rss-wxr-file-format/</link>
		<comments>http://huxuan.org/20110624/simplify-wordpress-extended-rss-wxr-file-format/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 08:25:41 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[sina2wor]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[WXR]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.huxuan.org/?p=1053</guid>
		<description><![CDATA[经过N次Import和数据库清空，终于将之前的WXR文件格式的完备集简化了。 简化原则是适应Sina2WordPress项目的需要，尽可能精简文件大小，删除了导入无效的（如博客标题、博客链接等）和从新浪博客中无法获取的（如评论者的链接和IP等）信息，还有item之前的的作者、分类和标签信息。作者在导入时可以指定的，反而加上会有可能的错误，分类和标签的信息用post中的分类和标签就可以自动统计了。没想明白为什么非要单独列出来，难道是为了空的分类和标签，那还要它干嘛？ 一些必不可少的标签及错误总结： 1、wxr_version，缺少会提示“missing/invalid WXR version number”的错误 2、post_id，否则只会导入第一篇文章 3、status，否则都会显示成draft 4、post_type，否则无法导入 5、comment_approved，否则无法导入 P.S.post_id的问题纠结了好久，为什么官方不好好设计一下呢？至少觉得应该在Settings设定对应的选项的…… &#60; ?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34; ?&#62; &#60;rss version=&#34;2.0&#34; xmlns:excerpt=&#34;http://wordpress.org/export/1.1/excerpt/&#34; xmlns:content=&#34;http://purl.org/rss/1.0/modules/content/&#34; xmlns:wfw=&#34;http://wellformedweb.org/CommentAPI/&#34; xmlns:dc=&#34;http://purl.org/dc/elements/1.1/&#34; xmlns:wp=&#34;http://wordpress.org/export/1.1/&#34; &#62; &#60;!--RSS版本号和名字空间的扩展，以上为固定内容--&#62; &#60;channel&#62; &#60;wp:wxr_version&#62;1.1&#60;/wp:wxr_version&#62; &#60;!--WXR格式版本号--&#62; &#60;item&#62;&#60;!--页面或者日志内容，每个为一个item--&#62; &#60;title&#62;Title test&#60;/title&#62; &#60;!--标题--&#62; &#60;content:encoded&#62;&#60; ![CDATA[Content_test]]&#62;&#60;/content:encoded&#62; &#60;!--这里是正文内容--&#62; &#60;wp:post_id&#62;1&#60;/wp:post_id&#62; &#60;!--页面或日志的序号，两者使用同一序列--&#62; &#60;wp:post_date&#62;2002-12-21 07:59:59&#60;/wp:post_date&#62; &#8230; <a href="http://huxuan.org/20110624/simplify-wordpress-extended-rss-wxr-file-format/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>经过N次Import和数据库清空，终于将之前的<a href="http://huxuan.org/analysis-of-wordpress-extended-rss-wxr-file/">WXR文件格式的完备集</a>简化了。</p>
<p>简化原则是适应Sina2WordPress项目的需要，尽可能精简文件大小，删除了导入无效的（如博客标题、博客链接等）和从新浪博客中无法获取的（如评论者的链接和IP等）信息，还有item之前的的作者、分类和标签信息。作者在导入时可以指定的，反而加上会有可能的错误，分类和标签的信息用post中的分类和标签就可以自动统计了。没想明白为什么非要单独列出来，难道是为了空的分类和标签，那还要它干嘛？</p>
<p>一些必不可少的标签及错误总结：<br />
1、wxr_version，缺少会提示“missing/invalid WXR version number”的错误<br />
2、post_id，否则只会导入第一篇文章<br />
3、status，否则都会显示成draft<br />
4、post_type，否则无法导入<br />
5、comment_approved，否则无法导入</p>
<p>P.S.post_id的问题纠结了好久，为什么官方不好好设计一下呢？至少觉得应该在Settings设定对应的选项的……</p>
<pre>
&lt; ?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;

&lt;rss version=&quot;2.0&quot;
	xmlns:excerpt=&quot;http://wordpress.org/export/1.1/excerpt/&quot;
	xmlns:content=&quot;http://purl.org/rss/1.0/modules/content/&quot;
	xmlns:wfw=&quot;http://wellformedweb.org/CommentAPI/&quot;
	xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot;
	xmlns:wp=&quot;http://wordpress.org/export/1.1/&quot;
&gt;
&lt;!--RSS版本号和名字空间的扩展，以上为固定内容--&gt;

&lt;channel&gt;
	&lt;wp:wxr_version&gt;1.1&lt;/wp:wxr_version&gt;
	&lt;!--WXR格式版本号--&gt;

	&lt;item&gt;&lt;!--页面或者日志内容，每个为一个item--&gt;
		&lt;title&gt;Title test&lt;/title&gt;
		&lt;!--标题--&gt;
		&lt;content:encoded&gt;&lt; ![CDATA[Content_test]]&gt;&lt;/content:encoded&gt;
		&lt;!--这里是正文内容--&gt;
		&lt;wp:post_id&gt;1&lt;/wp:post_id&gt;
		&lt;!--页面或日志的序号，两者使用同一序列--&gt;
		&lt;wp:post_date&gt;2002-12-21 07:59:59&lt;/wp:post_date&gt;
		&lt;!--发表时间--&gt;
		&lt;wp:comment_status&gt;open&lt;/wp:comment_status&gt;
		&lt;!--评论开启情况，open / closed--&gt;
		&lt;wp:status&gt;publish&lt;/wp:status&gt;
		&lt;!--页面或日志状态，publish / draft / pending / private--&gt;
		&lt;wp:post_type&gt;post&lt;/wp:post_type&gt;
		&lt;!--文章类型，post / page--&gt;
		&lt;wp:is_sticky&gt;0&lt;/wp:is_sticky&gt;
		&lt;!--文章是否置顶，0 / 1--&gt;

		&lt;category domain=&quot;post_tag&quot; nicename=&quot;tag_test&quot;&gt;&lt; ![CDATA[Tag Test]]&gt;&lt;/category&gt;
		&lt;category domain=&quot;category&quot; nicename=&quot;category_test&quot;&gt;&lt; ![CDATA[Category Test]]&gt;&lt;/category&gt;
		&lt;!--
			日志或页面的标签和分类，可多个
			domain：标签对应post_tag，分类对应category
			nicename：对应标签或分类的URL友好名称
			&lt;![CDATA[]]&gt;：标签或分类的显示名称
		--&gt;

		&lt;wp:comment&gt;&lt;!--评论，可多个--&gt;
			&lt;wp:comment_id&gt;1&lt;/wp:comment_id&gt;
			&lt;!--自增序号，评论专用--&gt;
			&lt;wp:comment_author&gt;&lt; ![CDATA[anonymous]]&gt;&lt;/wp:comment_author&gt;
			&lt;!--评论者用户名--&gt;
			&lt;wp:comment_date&gt;2012-12-21 07:59:59&lt;/wp:comment_date&gt;
			&lt;!--评论时间--&gt;
			&lt;wp:comment_content&gt;&lt; ![CDATA[Content of Comment]]&gt;&lt;/wp:comment_content&gt;
			&lt;!--评论内容--&gt;
			&lt;wp:comment_approved&gt;1&lt;/wp:comment_approved&gt;
			&lt;!--评论是否被允许--&gt;
			&lt;wp:comment_parent&gt;0&lt;/wp:comment_parent&gt;
			&lt;!--父评论，指定所回复的评论--&gt;
		&lt;/wp:comment&gt;
	&lt;/item&gt;
&lt;/channel&gt;
&lt;/rss&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20110624/simplify-wordpress-extended-rss-wxr-file-format/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WordPress eXtended Rss (WXR)文件格式解析</title>
		<link>http://huxuan.org/20110622/analysis-of-wordpress-extended-rss-wxr-file/</link>
		<comments>http://huxuan.org/20110622/analysis-of-wordpress-extended-rss-wxr-file/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 17:45:37 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[Sina2WordPress]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[WXR]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.huxuan.org/?p=1051</guid>
		<description><![CDATA[Sina2WordPress的第一步——解析WXR文件格式 WXR是Wordpress eXtended Rss的缩写，是WordPress针对博客信息特意设定的格式，它最大的优点是兼容性好，包含信息丰富 通过参照导出的文件，初步找到一个完备集（见下方代码），经测试在WP无任何内容情况下无信息缺漏错误现象 下方代码已经尽可能的注释了所有可能的标签和属性，并且由于一些标签和属性与Sina2WordPress关系不大，故未深究 &#60; ?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34; ?&#62; &#60;rss version=&#34;2.0&#34; xmlns:excerpt=&#34;http://wordpress.org/export/1.1/excerpt/&#34; xmlns:content=&#34;http://purl.org/rss/1.0/modules/content/&#34; xmlns:wfw=&#34;http://wellformedweb.org/CommentAPI/&#34; xmlns:dc=&#34;http://purl.org/dc/elements/1.1/&#34; xmlns:wp=&#34;http://wordpress.org/export/1.1/&#34; &#62; &#60;!--RSS版本号和名字空间的扩展，以上为固定内容--&#62; &#60;channel&#62; &#60;title&#62;Blog Title&#60;/title&#62; &#60;!--博客的标题--&#62; &#60;link&#62;http://blog.example.com&#60;/link&#62; &#60;!--博客的链接--&#62; &#60;description&#62;Blog Description&#60;/description&#62; &#60;!--博客的说明/副标题--&#62; &#60;pubdate&#62;Dec, 20 Jun 2012 23:59:59 +0000&#60;/pubdate&#62; &#60;!--WXR文件生成时间--&#62; &#60;language&#62;en&#60;/language&#62; &#60;!--博客的语言，en / zh-cn--&#62; &#8230; <a href="http://huxuan.org/20110622/analysis-of-wordpress-extended-rss-wxr-file/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sina2WordPress的第一步——解析WXR文件格式</p>
<p>WXR是Wordpress eXtended Rss的缩写，是WordPress针对博客信息特意设定的格式，它最大的优点是兼容性好，包含信息丰富</p>
<p>通过参照导出的文件，初步找到一个完备集（见下方代码），经测试在WP无任何内容情况下无信息缺漏错误现象</p>
<p>下方代码已经尽可能的注释了所有可能的标签和属性，并且由于一些标签和属性与Sina2WordPress关系不大，故未深究</p>
<pre>
&lt; ?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;

&lt;rss version=&quot;2.0&quot;
	xmlns:excerpt=&quot;http://wordpress.org/export/1.1/excerpt/&quot;
	xmlns:content=&quot;http://purl.org/rss/1.0/modules/content/&quot;
	xmlns:wfw=&quot;http://wellformedweb.org/CommentAPI/&quot;
	xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot;
	xmlns:wp=&quot;http://wordpress.org/export/1.1/&quot;
&gt;
&lt;!--RSS版本号和名字空间的扩展，以上为固定内容--&gt;

&lt;channel&gt;
	&lt;title&gt;Blog Title&lt;/title&gt;
	&lt;!--博客的标题--&gt;
	&lt;link&gt;http://blog.example.com&lt;/link&gt;
	&lt;!--博客的链接--&gt;
	&lt;description&gt;Blog Description&lt;/description&gt;
	&lt;!--博客的说明/副标题--&gt;
	&lt;pubdate&gt;Dec, 20 Jun 2012 23:59:59 +0000&lt;/pubdate&gt;
	&lt;!--WXR文件生成时间--&gt;
	&lt;language&gt;en&lt;/language&gt;
	&lt;!--博客的语言，en / zh-cn--&gt;
	&lt;wp:wxr_version&gt;1.1&lt;/wp:wxr_version&gt;
	&lt;!--WXR格式版本号--&gt;
	&lt;wp:base_site_url&gt;http://example.com&lt;/wp:base_site_url&gt;
	&lt;!--网站根目录地址--&gt;
	&lt;wp:base_blog_url&gt;http://blog.example.com&lt;/wp:base_blog_url&gt;
	&lt;!--博客根目录地址--&gt;

	&lt;wp:author&gt;&lt;wp:author_id&gt;1&lt;/wp:author_id&gt;&lt;wp:author_login&gt;admin_test&lt;/wp:author_login&gt;&lt;wp:author_email&gt;admin@example.org&lt;/wp:author_email&gt;&lt;wp:author_display_name&gt;&lt; ![CDATA[AdMin test]]&gt;&lt;/wp:author_display_name&gt;&lt;wp:author_first_name&gt;&lt; ![CDATA[AdMin]]&gt;&lt;/wp:author_first_name&gt;&lt;wp:author_last_name&gt;&lt; ![CDATA[test]]&gt;&lt;/wp:author_last_name&gt;&lt;/wp:author&gt;
	&lt;!--
		作者列表，可多个
		wp:author_id：自增序号
		wp:author_login：用户名
		wp:author_email：邮箱
		wp:author_display_name：显示的作者名称
		wp:author_first_name、wp:author_last_name：如字面意，可为空，但需有&lt;![CDATA[]]&gt;
		P.S.&lt; ![CDATA[**]]&gt;可以理解成强制文本转换，保留文本中所有字符，以避免非法字符对XML文件的影响（后文不再赘述）
	--&gt;

	&lt;wp:category&gt;&lt;wp:term_id&gt;1&lt;/wp:term_id&gt;&lt;wp:category_nicename&gt;category_test&lt;/wp:category_nicename&gt;&lt;wp:category_parent&gt;&lt;/wp:category_parent&gt;&lt;wp:cat_name&gt;&lt; ![CDATA[分类测试]]&gt;&lt;/wp:cat_name&gt;&lt;/wp:category&gt;
	&lt;!--
		分类列表，可多个
		wp:term_id：自增序号，且分类和标签用的是同一个
		wp:category_nicename：URL友好名称，作为相关URL的一部分
		wp:category_parent：父分类，无即为空
		wp:cat_name：显示的分类名称
	--&gt;

	&lt;wp:tag&gt;&lt;wp:term_id&gt;2&lt;/wp:term_id&gt;&lt;wp:tag_slug&gt;tag_test&lt;/wp:tag_slug&gt;&lt;wp:tag_name&gt;&lt; ![CDATA[标签测试]]&gt;&lt;/wp:tag_name&gt;&lt;/wp:tag&gt;
	&lt;!--
		标签列表，可多个
		wp:term_id：自增序号，与标签使用同一个序列
		wp:tag_slug：URL友好名称，作为相关URL的一部分
		wp:tag_name：显示的标签名称
	--&gt;

	&lt;generator&gt;http://wordpress.org/?v=3.1.3&lt;/generator&gt;&lt;!--WXR文件生成工具的标识--&gt;

	&lt;item&gt;&lt;!--页面或者日志内容，每个为一个item--&gt;
		&lt;title&gt;Title&lt;/title&gt;
		&lt;!--标题--&gt;
		&lt;link&gt;http://blog.example.com/title/&lt;/link&gt;
		&lt;!--URL地址--&gt;
		&lt;pubdate&gt;Thu, 15 Apr 2010 23:20:03 +0000&lt;/pubdate&gt;
		&lt;!--发布时间--&gt;
		&lt;dc:creator&gt;admin&lt;/dc:creator&gt;
		&lt;!--文章作者--&gt;
		&lt;guid isPermaLink=&quot;false&quot;&gt;http://blog.example.com/?page_id=1&lt;/guid&gt;
		&lt;!--
			GUID 意为 Global Unique IDentification，即全局唯一标识
			isPermaLink=&quot;false&quot; 指示该地址非合法URL地址的属性
		--&gt;
		&lt;description&gt;&lt;/description&gt;
		&lt;content:encoded&gt;&lt; ![CDATA[Content_test_1]]&gt;&lt;/content:encoded&gt;
		&lt;!--这里是正文内容--&gt;
		&lt;excerpt:encoded&gt;&lt; ![CDATA[]]&gt;&lt;/excerpt:encoded&gt;
		&lt;!--文章摘录，供RSS/Atom使用，一般为空--&gt;
		&lt;wp:post_id&gt;2&lt;/wp:post_id&gt;
		&lt;!--页面或日志的序号，两者使用同一序列--&gt;
		&lt;wp:post_date&gt;2012-12-21 07:59:5&lt;/wp:post_date&gt;
		&lt;!--发表时间--&gt;
		&lt;wp:post_date_gmt&gt;2010-12-20 23:59:59&lt;/wp:post_date_gmt&gt;
		&lt;!--发表时间（GMT）--&gt;
		&lt;wp:comment_status&gt;open&lt;/wp:comment_status&gt;
		&lt;!--评论开启情况，open / closed--&gt;
		&lt;wp:ping_status&gt;closed&lt;/wp:ping_status&gt;
		&lt;!--Ping开启情况，open / closed--&gt;
		&lt;wp:post_name&gt;blog_title&lt;/wp:post_name&gt;
		&lt;!--URL友好的名称--&gt;
		&lt;wp:status&gt;publish&lt;/wp:status&gt;
		&lt;!--页面或日志状态，publish / draft / pending / private--&gt;
		&lt;wp:post_parent&gt;0&lt;/wp:post_parent&gt;
		&lt;!--只用于页面，指示父页面的id--&gt;
		&lt;wp:menu_order&gt;0&lt;/wp:menu_order&gt;
		&lt;!--只用与页面，作为导航时的排序权值--&gt;
		&lt;wp:post_type&gt;post&lt;/wp:post_type&gt;
		&lt;!--文章类型，post / page--&gt;
		&lt;wp:post_password&gt;&lt;/wp:post_password&gt;
		&lt;!--文章是否加密--&gt;
		&lt;wp:is_sticky&gt;0&lt;/wp:is_sticky&gt;
		&lt;!--文章是否置顶，0 / 1--&gt;

		&lt;category domain=&quot;post_tag&quot; nicename=&quot;tag_test&quot;&gt;&lt; ![CDATA[Tag Test]]&gt;&lt;/category&gt;
		&lt;category domain=&quot;category&quot; nicename=&quot;category_test&quot;&gt;&lt; ![CDATA[Category]]&gt;&lt;/category&gt;
		&lt;!--
			日志或页面的标签和分类，可多个
			domain：标签对应post_tag，分类对应category
			nicename：对应标签或分类的URL友好名称
			&lt;![CDATA[]]&gt;：标签或分类的显示名称
		--&gt;

		&lt;wp:postmeta&gt;&lt;!--日志或页面的元数据，可多个--&gt;
			&lt;wp:meta_key&gt;_edit_last&lt;/wp:meta_key&gt;
			&lt;!--元数据的关键字--&gt;
			&lt;wp:meta_value&gt;&lt; ![CDATA[1]]&gt;&lt;/wp:meta_value&gt;
			&lt;!--元数据对应关键字的值--&gt;
		&lt;/wp:postmeta&gt;

		&lt;wp:comment&gt;&lt;!--评论，可多个--&gt;
			&lt;wp:comment_id&gt;1&lt;/wp:comment_id&gt;
			&lt;!--自增序号，评论专用--&gt;
			&lt;wp:comment_author&gt;&lt; ![CDATA[anonymous]]&gt;&lt;/wp:comment_author&gt;&gt;
			&lt;!--评论者用户名--&gt;
			&lt;wp:comment_author_email&gt;anonymous@anonymous.com&lt;/wp:comment_author_email&gt;
			&lt;!--评论者邮箱--&gt;
			&lt;wp:comment_author_url&gt;http://blog.anonymous.com&lt;/wp:comment_author_url&gt;
			&lt;!--评论者链接--&gt;
			&lt;wp:comment_author_ip&gt;8.8.8.8&lt;/wp:comment_author_ip&gt;
			&lt;!--评论者IP--&gt;
			&lt;wp:comment_date&gt;2012-12-21 07:59:59&lt;/wp:comment_date&gt;
			&lt;!--评论时间--&gt;
			&lt;wp:comment_date_gmt&gt;2012-12-20 23:59:59&lt;/wp:comment_date_gmt&gt;
			&lt;!--评论时间（GMT）--&gt;
			&lt;wp:comment_content&gt;&lt; ![CDATA[Content of Comment]]&gt;&lt;/wp:comment_content&gt;
			&lt;!--评论内容--&gt;
			&lt;wp:comment_approved&gt;1&lt;/wp:comment_approved&gt;
			&lt;!--评论是否被允许--&gt;
			&lt;wp:comment_type&gt;&lt;/wp:comment_type&gt;
			&lt;!--评论类型，空白表示一般评论，否则会标记位pingback--&gt;
			&lt;wp:comment_parent&gt;0&lt;/wp:comment_parent&gt;
			&lt;!--父评论，指定所回复的评论--&gt;
			&lt;wp:comment_user_id&gt;0&lt;/wp:comment_user_id&gt;
			&lt;!--如果评论者为注册用户，这里会记录用户ID--&gt;
		&lt;/wp:comment&gt;
	&lt;/item&gt;
&lt;/channel&gt;
&lt;/rss&gt;
</pre>
<p><strong>参考：</strong><a href="http://ipggi.wordpress.com/2011/03/16/the-wordpress-extended-rss-wxr-exportimport-xml-document-format-decoded-and-explained/">http://ipggi.wordpress.com/2011/03/16/the-wordpress-extended-rss-wxr-exportimport-xml-document-format-decoded-and-explained/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20110622/analysis-of-wordpress-extended-rss-wxr-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>VPS杂记</title>
		<link>http://huxuan.org/20110603/vps-notes/</link>
		<comments>http://huxuan.org/20110603/vps-notes/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 09:29:10 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lnmp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.huxuan.org/?p=1048</guid>
		<description><![CDATA[入手VPS好久了，用的是LNMP架构，在Evernote中压了一些笔记，一一贴出来示众～ 安装lnmp 注：版本可能有更新，0.7为截至2011/06/03的最新版 wget http://soft.vpser.net/lnmp/lnmp0.7.tar.gz tar zxvf lnmp0.7.tar.gz cd lnmp0.7/ ./ubuntu.sh 创建虚拟主机 /root/vhost.sh root账户的使用 平时使用普通账户登录，需要使用root权限的时候用su命令，然后再输入root命令，使用完root权限之后可以用ctrl+D退出权限，继续使用普通账户权限，这样可以防止权限的混乱 安装OpenVPN wget http://vpsnoc.com/scripts/debian-openvpn.sh chmod +x debian-openvpn.sh ./debian-openvpn.sh 按照提示安装完成后下载keys.tgz，将其解压到OpenVPN安装目录下的config子目录，然后启动OpenVPN就可以使用了 wordpress的rewrite问题 默认的规则有点小问题，替换为以下的即可： if (!-e $request_filename) { rewrite (.*) /index.php; } WordPress文件权限 chown -R www.www /blog]]></description>
			<content:encoded><![CDATA[<p>入手VPS好久了，用的是LNMP架构，在Evernote中压了一些笔记，一一贴出来示众～</p>
<p><strong>安装lnmp</strong><br />
注：版本可能有更新，0.7为截至2011/06/03的最新版</p>
<pre>
wget http://soft.vpser.net/lnmp/lnmp0.7.tar.gz
tar zxvf lnmp0.7.tar.gz
cd lnmp0.7/
./ubuntu.sh
</pre>
<p><strong>创建虚拟主机</strong></p>
<pre>
/root/vhost.sh
</pre>
<p><strong>root账户的使用 </strong><br />
平时使用普通账户登录，需要使用root权限的时候用su命令，然后再输入root命令，使用完root权限之后可以用ctrl+D退出权限，继续使用普通账户权限，这样可以防止权限的混乱</p>
<p><strong>安装OpenVPN</strong></p>
<pre>
wget http://vpsnoc.com/scripts/debian-openvpn.sh
chmod +x debian-openvpn.sh
./debian-openvpn.sh
</pre>
<p>按照提示安装完成后下载keys.tgz，将其解压到OpenVPN安装目录下的config子目录，然后启动OpenVPN就可以使用了</p>
<p><strong>wordpress的rewrite问题</strong><br />
默认的规则有点小问题，替换为以下的即可：</p>
<pre>
if  (!-e $request_filename)
{
    rewrite (.*) /index.php;
}
</pre>
<p><strong>WordPress文件权限</strong></p>
<pre>
chown -R www.www /blog
</pre>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20110603/vps-notes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>解决在Ubuntu上搭建Android开发环境缺少WST包的问题</title>
		<link>http://huxuan.org/20110603/slove-the-lack-of-wst-package-when-installing-android-development-environment-on-ubuntu/</link>
		<comments>http://huxuan.org/20110603/slove-the-lack-of-wst-package-when-installing-android-development-environment-on-ubuntu/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 08:56:29 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.huxuan.org/?p=1046</guid>
		<description><![CDATA[前言：之前写过一篇《Ubuntu 10.04安装Android开发环境》，每天都有不少访问量，估计很多就是遇到了这个问题，一直压在Evernote里没有翻出来，现在已转入Arch阵营，没有再次验证解决方案的正确性，完全参照印象和笔记，有问题尽管留言 平台：Ubuntu 10.10和Ubuntu 11.04，10.04（写那一篇日志的时候）无此问题 原因：Ubuntu下的Eclipse是Ubuntu社区打包的，非完整版，少了WST包的支持 现象：安装ADT的时候会提示类似如下错误(版本号可能会有不同)： Cannot complete the install because one or more required items could not be found. Software being installed: Android Development Tools 10.0.1.v201103111512-110841 (com.android.ide.eclipse.adt.feature.group 0.0.1.v201103111512-110841) Missing requirement: Android Development Tools 10.0.1.v201103111512-10841 (com.android.ide.eclipse.adt.feature.group 10.0.1.v201103111512-110841) requires 'org.eclipse.wst.sse.core &#8230; <a href="http://huxuan.org/20110603/slove-the-lack-of-wst-package-when-installing-android-development-environment-on-ubuntu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>前言</strong>：之前写过一篇《<a href="http://huxuan.org/install_android_development_environment_on_ubuntu_10_04/">Ubuntu 10.04安装Android开发环境</a>》，每天都有不少访问量，估计很多就是遇到了这个问题，一直压在Evernote里没有翻出来，现在已转入Arch阵营，没有再次验证解决方案的正确性，完全参照印象和笔记，有问题尽管留言</p>
<p><strong>平台</strong>：Ubuntu 10.10和Ubuntu 11.04，10.04（写那一篇日志的时候）无此问题</p>
<p><strong>原因</strong>：Ubuntu下的Eclipse是Ubuntu社区打包的，非完整版，少了WST包的支持</p>
<p><strong>现象</strong>：安装ADT的时候会提示类似如下错误(版本号可能会有不同)：</p>
<pre>
Cannot complete the install because one or more required items could not be found.  Software being installed: Android Development Tools 10.0.1.v201103111512-110841 (com.android.ide.eclipse.adt.feature.group 0.0.1.v201103111512-110841)  Missing requirement: Android Development Tools 10.0.1.v201103111512-10841 (com.android.ide.eclipse.adt.feature.group 10.0.1.v201103111512-110841) requires 'org.eclipse.wst.sse.core 0.0.0' but it could not be found
</pre>
<p><strong>解决方案</strong>：<br />
方案1：直接从Eclipse官网下载完整的安装包<br />
方案2：遵照以下菜单顺序或提示执行</p>
<pre>
1：Help --> Install New Software --> Add --> type 'http://download.eclipse.org/releases/galileo' in the Location -->OK
2：Help --> Install New Software --> Add --> type 'http://dl.google.com/eclipse/plugin/3.5' in the Location --> OK
3：Please make sure the option 'Contact all updates sites during install to find required software' is checked.
4：Restart Eclipse，Reinstall ADT
</pre>
<p><strong>相关参照</strong>：<br />
1)<a href="http://code.google.com/intl/es/eclipse/docs/faq.html#wstinstallerror">http://code.google.com/intl/es/eclipse/docs/faq.html#wstinstallerror</a><br />
2)<a href="http://code.google.com/intl/es/eclipse/docs/install-eclipse-3.5.html">http://code.google.com/intl/es/eclipse/docs/install-eclipse-3.5.html</a></p>
<p>P.S.本文参与“<a href="http://www.google.com/daxue/blog">第二届 Google 暑期大学生博客分享大赛 &#8211; 2011 Android 成长篇</a>”，感谢大家支持</p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20110603/slove-the-lack-of-wst-package-when-installing-android-development-environment-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shell 自动补全</title>
		<link>http://huxuan.org/20110501/shell-%e8%87%aa%e5%8a%a8%e8%a1%a5%e5%85%a8/</link>
		<comments>http://huxuan.org/20110501/shell-%e8%87%aa%e5%8a%a8%e8%a1%a5%e5%85%a8/#comments</comments>
		<pubDate>Sun, 01 May 2011 04:40:23 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://blog.huxuan.org/?p=1043</guid>
		<description><![CDATA[1) /etc/passwd It shows like this huxuan:x:1002:1002::/home/huxuan:/bin/bash in format of Username:Password:User ID (UID):Group ID (GID):User ID Info:Home directory:Command/shell Make sure the Command/shell is the &#8220;/bin/bash&#8221; and not the &#8220;/bin/sh&#8221; which may be the default value. 2) $HOME$/.bashrc or /etc/bash.bashrc Make &#8230; <a href="http://huxuan.org/20110501/shell-%e8%87%aa%e5%8a%a8%e8%a1%a5%e5%85%a8/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>1) /etc/passwd</p>
<p>It shows like this</p>
<pre>huxuan:x:1002:1002::/home/huxuan:/bin/bash</pre>
<p>in format of </p>
<pre>Username:Password:User ID (UID):Group ID (GID):User ID Info:Home directory:Command/shell</pre>
<p>Make sure the Command/shell is the &#8220;/bin/bash&#8221; and not the &#8220;/bin/sh&#8221; which may be the default value.</p>
<p>2) $HOME$/.bashrc or /etc/bash.bashrc<br />
Make sure the code blew is not commented out.</p>
<pre>if [ -f /etc/bash_completion ] &#038;&#038; ! shopt -oq posix; then
    . /etc/bash_completion
fi</pre>
<p>3) Reference<br />
<a href="http://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/">http://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20110501/shell-%e8%87%aa%e5%8a%a8%e8%a1%a5%e5%85%a8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用密钥自动登录SSH（更新ssh-copy-id）</title>
		<link>http://huxuan.org/20110430/key-use-to-login-ssh-update/</link>
		<comments>http://huxuan.org/20110430/key-use-to-login-ssh-update/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 06:57:13 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://blog.huxuan.org/?p=1041</guid>
		<description><![CDATA[【更新】 经lyxint提醒，发现了ssh-copy-id命令，第二步可以更简单的实现 ssh-copy-id -i ~/.ssh/id_rsa.pub username@hostname 其中username为用户名，hostname为服务器\VPS的IP\地址 1）在本机生成公钥密钥 ssh-keygen -t rsa 一路回车，选择默认路径即可，默认路径为~/.ssh/ 2）将本地公钥上传至服务器 cat ~/.ssh/id_rsa.pub&#124;ssh username@hostname &#8216;sh -c &#8220;cat &#8211; >>~/.ssh/authorized_keys&#8221;&#8216; 其中username为用户名，hostname为服务器\VPS的IP\地址 3）ssh设置文件的几点说明（一般是默认即可） 路径：/etc/ssh/sshd_config 相关行: PubkeyAuthentication yes #开启公钥验证 #AuthorizedKeysFile %h/.ssh/authorized_keys #公钥的位置，建议使用默认路径]]></description>
			<content:encoded><![CDATA[<p><strong>【更新】</strong><br />
经<a href="http://lyxint.com/">lyxint</a>提醒，发现了ssh-copy-id命令，第二步可以更简单的实现<br />
ssh-copy-id -i ~/.ssh/id_rsa.pub username@hostname<br />
其中username为用户名，hostname为服务器\VPS的IP\地址</p>
<p>1）在本机生成公钥密钥<br />
ssh-keygen -t rsa<br />
一路回车，选择默认路径即可，默认路径为~/.ssh/</p>
<p>2）将本地公钥上传至服务器<br />
cat ~/.ssh/id_rsa.pub|ssh username@hostname &#8216;sh -c &#8220;cat &#8211; >>~/.ssh/authorized_keys&#8221;&#8216;<br />
其中username为用户名，hostname为服务器\VPS的IP\地址</p>
<p>3）ssh设置文件的几点说明（一般是默认即可）<br />
路径：/etc/ssh/sshd_config<br />
相关行:<br />
     PubkeyAuthentication yes #开启公钥验证<br />
     #AuthorizedKeysFile     %h/.ssh/authorized_keys #公钥的位置，建议使用默认路径</p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20110430/key-use-to-login-ssh-update/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>LaTeX笔记(1)</title>
		<link>http://huxuan.org/20110426/latex-notes-1/</link>
		<comments>http://huxuan.org/20110426/latex-notes-1/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 08:44:27 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Reading Notes]]></category>

		<guid isPermaLink="false">http://blog.huxuan.org/?p=1038</guid>
		<description><![CDATA[取消连字符 \sloppy: 弱命令 效果不是很明显，但是基本保证布局美观 \pretolerance=10000: 强命令 效果很明显，几乎可以去掉所有连字符，但是对布局影响很大 10000是一个阈值，可以适当变小，可能会有比较折中的效果 补救措施：在字符间距非常大的地方用 \- 命令强制生成连字符 引号 ` ` : 左双引号(两个小撇，和波浪号同一个键) ` : 左单引号(一个小撇，同上) &#8216; &#8216; : 右双引号(两个单引号) &#8216; : 右单引号(一个单引号) P.S.请不要直接复制粘贴，中间有空格，为了HTML下的显示需要 强制不分行 \mbox{content here will not be split up} 四级标题 \section{} \subsection{} \subsubsection{} \paragraph{*.*.*.* &#8230; <a href="http://huxuan.org/20110426/latex-notes-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>取消连字符</strong><br />
\sloppy: 弱命令<br />
效果不是很明显，但是基本保证布局美观</p>
<p>\pretolerance=10000: 强命令<br />
效果很明显，几乎可以去掉所有连字符，但是对布局影响很大<br />
10000是一个阈值，可以适当变小，可能会有比较折中的效果<br />
补救措施：在字符间距非常大的地方用 \- 命令强制生成连字符</p>
<p><strong>引号</strong><br />
` ` : 左双引号(两个小撇，和波浪号同一个键)<br />
` : 左单引号(一个小撇，同上)<br />
&#8216; &#8216; : 右双引号(两个单引号)<br />
&#8216; : 右单引号(一个单引号)<br />
P.S.请不要直接复制粘贴，中间有空格，为了HTML下的显示需要</p>
<p><strong>强制不分行</strong><br />
\mbox{content here will not be split up}</p>
<p><strong>四级标题</strong><br />
\section{}<br />
\subsection{}<br />
\subsubsection{}<br />
\paragraph{*.*.*.* }</p>
<p><strong>波浪线</strong><br />
\~{}</p>
<p><strong>上角标</strong><br />
\textsuper{}: 非数学环境<br />
^{}: 数学环境</p>
<p><strong>首段缩进（默认不缩进）</strong><br />
\usepackage{indentfirst}</p>
<p><strong>推荐的格式设置</strong><br />
\documentclass[a4paper,12pt]{article}: 纸张类型，主体字号，文档类型<br />
\usepackage[top=1in,bottom=1in,left=1.25in,right=1.25in]{geometry}: 页边距</p>
<p><strong>简历模板</strong></p>
<p>http://www.ctan.org/tex-archive/macros/latex/contrib/tucv</p>
<p><strong>超链接去边框和颜色</strong><br />
\usepackage[colorlinks,allcolors=black]{hyperref}</p>
<p><strong>嵌入所有字体</strong><br />
dvips -Pdownload35 inputfilename.dvi</p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20110426/latex-notes-1/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Android平台下FreePascal的交叉编译器</title>
		<link>http://huxuan.org/20110412/corsscompiler-to-run-free-pascal-on-android/</link>
		<comments>http://huxuan.org/20110412/corsscompiler-to-run-free-pascal-on-android/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 06:12:18 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[CorssCompiler]]></category>
		<category><![CDATA[FreePascal]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.huxuan.org/?p=1034</guid>
		<description><![CDATA[0) Preface 0.1) The Operating System is Ubuntu 10.10 0.2) All the softwares are the latest stable version by April 12, 2011 1) Download the Source of Free Pascal Compiler The &#8216;fpc-2.4.2.source.tar.gz&#8217; on http://sourceforge.net/projects/freepascal/files/Source/2.4.2/ 2) Install the fpc-source. Just extract &#8230; <a href="http://huxuan.org/20110412/corsscompiler-to-run-free-pascal-on-android/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>0) Preface<br />
0.1) The Operating System is Ubuntu 10.10<br />
0.2) All the softwares are the latest stable version by April 12, 2011</p>
<p>1) Download the Source of Free Pascal Compiler<br />
The &#8216;fpc-2.4.2.source.tar.gz&#8217; on <a href="http://sourceforge.net/projects/freepascal/files/Source/2.4.2/">http://sourceforge.net/projects/freepascal/files/Source/2.4.2/</a></p>
<p>2) Install the fpc-source. Just extract it.<br />
The root folder of fpc-source for me is &#8216;/home/victorhu/fpc-source&#8217;</p>
<p>3) Download the Arm-Eabi (Sourcery G++ Lite 2010.09-50 for ARM GNU/Linux)<br />
The &#8216;IA32 GNU/Linux Installer&#8217; on <a href="http://www.codesourcery.com/sgpp/lite/arm/portal/release1600">http://www.codesourcery.com/sgpp/lite/arm/portal/release1600</a></p>
<p>4) Install the Arm-Eabi (Sourcery G++ Lite 2010.09-50 for ARM GNU/Linux)<br />
The installation need the system shell to be bash not dash which is default for Ubuntu. So<br />
4.1)
<pre>sudo dpkg-reconfigure -plow dash</pre>
<p> Choose NO to make the bash as the system shell.<br />
4.2) Goto the root folder of Arm-Eabi for me is &#8216;/home/victorhu/toolchain/&#8217;<br />
4.3)
<pre>chmod +x arm-2010.09-05-arm-none-linux-gnueabi.bin</pre>
<p>4.4)
<pre>./arm-2010.09-05-arm-none-linux-gnueabi.bin</pre>
<p>5) Get the Cross Compiler<br />
5.1) Goto the root folder of fpc-source<br />
5.2)
<pre>make crossall CPU_TARGET=arm OS_TARGET=linux OPT="-dFPC_ARMEL -O- -gl"  CROSSPORT="-O-" CROSSBINDIR=/home/victorhu/toolchain/arm-none-linux-gnueabi/bin</pre>
<p>5.3) The &#8216;ppcrossarm&#8217; under &#8216;/home/victorhu/fpc-source/compilers/&#8217; is just what we want.<br />
Note: CROSSBINDIR is depend on the folder of Arm-Eabi.</p>
<p>6) Write a Hello Word in Pascal<br />
The path for me is /home/victorhu/hello.pas</p>
<pre>
Program hello;
begin
writeln('Hello World!');
end.
</pre>
<p>7) Compile the Hello World in Pascal via CrossCompile Environment.<br />
7.1) Goto the folder contains &#8216;ppcrossarm&#8217;<br />
7.2)
<pre>./ppcrossarm -Tlinux -O- -XP -Fu/home/victorhu/fpc-source/rtl/units/arm-linux/ -FD/home/victorhu/toolchain/arm-none-linux-gnueabi/bin /home/victorhu/hello.pas</pre>
<p>Note: -Fu is the unit path, -FD is the compiler utilities path.<br />
7.3) The &#8216;hello&#8217; under &#8216;/home/victorhu/temp&#8217; is just the what we want (not hello.pas).</p>
<p>8) Test the Crosscompiled Hello World in Android Emulator<br />
8.1) the tools under Android SDK or the ADT of Eclipse is where we can find it.<br />
8.2) Goto the adb root folder under Android SDK .<br />
It&#8217;s &#8216;platform-tools&#8217; under the main root folder of Android SDK now while it&#8217;s &#8216;tools&#8217; before.<br />
8.3) Test whether is device is connected. </p>
<pre>./adb devices</pre>
<p>If it shows somthing like &#8216;Emulator-5544 device&#8217; (for me), then it&#8217;s right.<br />
8.4) Push the program into Android Emulator.</p>
<pre>./adb push ~/hello /data/hello</pre>
<p>8.5) Run the program on the Android Emulator.</p>
<pre>./adb shell data/hello</pre>
<p>If it shows &#8216;Hello World!&#8217; (the result of the original program), then everything is done now!</p>
<p>9) Reference<br />
9.1) <a href="http://alexmogurenko.com/blog/programming/android-building-free-pascal-compiler-for-android/">http://alexmogurenko.com/blog/programming/android-building-free-pascal-compiler-for-android/</a><br />
9.2) <a href="http://wiki.freepascal.org/Android_Interface">http://wiki.freepascal.org/Android_Interface</a><br />
9.3) <a href="http://wiki.freepascal.org/Setup_Cross_Compile_For_ARM">http://wiki.freepascal.org/Setup_Cross_Compile_For_ARM</a></p>
<p>P.S.本文参与“<a href="http://www.google.com/daxue/blog">第二届 Google 暑期大学生博客分享大赛 &#8211; 2011 Android 成长篇</a>”，感谢大家支持</p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20110412/corsscompiler-to-run-free-pascal-on-android/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>《Math into LaTeX》读书笔记</title>
		<link>http://huxuan.org/20100828/math-into-latex/</link>
		<comments>http://huxuan.org/20100828/math-into-latex/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 06:08:47 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Reading Notes]]></category>
		<category><![CDATA[Xmind]]></category>

		<guid isPermaLink="false">http://blog.huxuan.org/?p=986</guid>
		<description><![CDATA[《Math into LaTeX》是《More Math into LaTeX》的第一部分Short Course。 (完整版找不到官方链接了，如果网盘过期了说一声) 顾名思义，一本不错的入门教程，完整版600+页也确实让人心寒……献丑思维导图一枚～]]></description>
			<content:encoded><![CDATA[<p><a href="ftp://ftp.ctex.org/mirrors/CTAN/info/Math_into_LaTeX-4/Short_Course.pdf" target="_blank">《Math into LaTeX》</a>是<a href="http://u.115.com/file/f1b08a0c33" target="_blank">《More Math into LaTeX》</a>的第一部分Short Course。<br />
(完整版找不到官方链接了，如果网盘过期了说一声)<br />
顾名思义，一本不错的入门教程，完整版600+页也确实让人心寒……献丑<a href="http://www.xmind.net/share/_embed/huxuan/math-into-latex/" target="_blank">思维导图</a>一枚～<br />
<iframe id='xmindshare_embedviewer' src='http://xmind.net/share/_embed/huxuan/math-into-latex/' width='625px' height='250px' frameborder='0' scrolling='no'></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20100828/math-into-latex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>《一份不太简短的LaTeX2e介绍》读书笔记</title>
		<link>http://huxuan.org/20100821/the-not-so-short-introduction-to-latex2e/</link>
		<comments>http://huxuan.org/20100821/the-not-so-short-introduction-to-latex2e/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 12:37:23 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Reading Notes]]></category>
		<category><![CDATA[Xmind]]></category>

		<guid isPermaLink="false">http://blog.huxuan.org/?p=984</guid>
		<description><![CDATA[LaTeX是一款著名的排版系统，久闻而未见其面，实验室正好要做这方面的工作，是以学习这款软件 推荐这本入门教程，比较全面但又不至于冗长，下载地址（中文、英文），如下载链接失效，请留言联系。附鄙人的思维导图一枚～]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/LaTeX" target="_blank">LaTeX</a>是一款著名的排版系统，久闻而未见其面，实验室正好要做这方面的工作，是以学习这款软件<br />
推荐这本入门教程，比较全面但又不至于冗长，下载地址（<a href="http://mirror.bjtu.edu.cn/CTAN/info/lshort/chinese.zip" target="_blank">中文</a>、<a href="http://ftp.ctex.org/mirrors/CTAN/info/lshort/english.zip" target="_blank">英文</a>），如下载链接失效，请留言联系。附鄙人的<a href="http://www.xmind.net/share/_embed/huxuan/a-very-brief-introduction-latex2e/" target="_blank">思维导图</a>一枚～</p>
<p><iframe id='xmindshare_embedviewer' src='http://xmind.net/share/_embed/huxuan/a-very-brief-introduction-latex2e/' width='625px' height='250px' frameborder='0' scrolling='no'></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20100821/the-not-so-short-introduction-to-latex2e/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu 10.04安装Android开发环境（更新解决WST包缺少问题）</title>
		<link>http://huxuan.org/20100813/install_android_development_environment_on_ubuntu_10_04/</link>
		<comments>http://huxuan.org/20100813/install_android_development_environment_on_ubuntu_10_04/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 01:04:13 +0000</pubDate>
		<dc:creator>Shane.Hu</dc:creator>
				<category><![CDATA[IT水手]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.huxuan.org/?p=977</guid>
		<description><![CDATA[更新：在10.10及11.04中搭建时可能会遇到WST包缺少的问题，可以参照这篇日志解决 注：本文中&#60;android_sdk&#62;代表Android SDK安装路径 这里选择&#8221;/home/victorhu/Code/android-sdk-linux_86&#8243; Step 0 : 准备 sudo apt-get update Step 1 : 安装 Java JDK &#038; Eclipse sudo apt-get install sun-java6-jdk eclipse Step 2 : 安装 Andorid SDK Starter Package wget http://dl.google.com/android/android-sdk_r06-linux_86.tgz tar -zxvf android-sdk_r06-linux_86.tgz 你可以把这个文件放在任意你希望的位置，这就是Andord SDK的安装位置 Step &#8230; <a href="http://huxuan.org/20100813/install_android_development_environment_on_ubuntu_10_04/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>更新</strong>：在10.10及11.04中搭建时可能会遇到WST包缺少的问题，可以参照<a href="http://blog.huxuan.org/slove-the-lack-of-wst-package-when-installing-android-development-environment-on-ubuntu/">这篇日志</a>解决</p>
<p><strong>注：本文中&lt;android_sdk&gt;代表Android SDK安装路径</strong><br />
这里选择&#8221;/home/victorhu/Code/android-sdk-linux_86&#8243;</p>
<p><strong>Step 0 : 准备</strong></p>
<pre>sudo apt-get update</pre>
<p><strong>Step 1 : 安装 Java JDK &#038; Eclipse</strong></p>
<pre>sudo apt-get install sun-java6-jdk eclipse</pre>
<p><strong>Step 2 : 安装 Andorid SDK Starter Package</strong></p>
<pre>wget http://dl.google.com/android/android-sdk_r06-linux_86.tgz
tar -zxvf android-sdk_r06-linux_86.tgz</pre>
<p>你可以把这个文件放在任意你希望的位置，这就是Andord SDK的安装位置</p>
<p><strong>Step 3 : 配置环境</strong></p>
<pre>export PATH=${PATH}:&lt;android_sdk&gt;/tools</pre>
<p>如运行时出现&#8221;The project cannot be built until build path errors are resolved&#8221;错误，请检查此步</p>
<p><strong>Setp 4 : 安装 ADT Plugin for Eclipse</strong><br />
在Eclipse中选择&#8221;Help&#8221; &#8211;> &#8220;Install New Software&#8221;将出现类似下方画面<br />
<a href="http://www.flickr.com/photos/victorhu_cn/4886901584/" title="Flickr 上 凝云幻龙 的 1"><img src="http://farm5.static.flickr.com/4082/4886901584_f490c2d9ca.jpg" width="500" height="436" alt="1" /></a><br />
在&#8221;Work with&#8221;区域填上&#8221;https://dl-ssl.google.com/android/eclipse/&#8221;然后选择&#8221;Add&#8221;<br />
此时会显示类似上方的画面，勾选&#8221;Develop Tools&#8221;点击&#8221;Next&#8221;，剩余步骤同一般程序安装<br />
<strong>更新：如果此处遇到WST包缺少的问题，可以参照<a href="http://blog.huxuan.org/slove-the-lack-of-wst-package-when-installing-android-development-environment-on-ubuntu/">这篇日志</a>解决</strong><br />
（可能会遇到证书错误，选择继续安装即可）</p>
<p><strong>Step 5 : 配置 SDK</strong><br />
在Eclipse中选择&#8221;Windows&#8221; &#8211;> &#8220;Preferences&#8221;，然后在左侧选择&#8221;Android&#8221;可得到类似下方画面<br />
<a href="http://www.flickr.com/photos/victorhu_cn/4886901288/" title="Flickr 上 凝云幻龙 的 2"><img src="http://farm5.static.flickr.com/4073/4886901288_b7f3781c51.jpg" width="500" height="367" alt="2" /></a><br />
点击&#8221;Browse&#8221;选择Android SDK安装路径，此时会在&#8221;SDK Location&#8221;处显示，点击&#8221;Apply&#8221;使配置生效</p>
<p><strong>Step 6 : 下载 SDK package</strong><br />
在Eclipse中选择&#8221;Windows&#8221; &#8211;> &#8220;Android SDK and AVD manager&#8221;，在左侧选择&#8221;Available&#8221;<br />
选择所有（如下图所示），然后开始安装&#8221;Install Selected&#8221;<br />
<a href="http://www.flickr.com/photos/victorhu_cn/4886299357/" title="Flickr 上 凝云幻龙 的 3"><img src="http://farm5.static.flickr.com/4116/4886299357_12447d732c.jpg" width="500" height="266" alt="3" /></a><br />
附两张过程中的截图: 1、选择&#8221;Accept All&#8221;比较方便; 2、下载可能需要花费比较长的时间<br />
<a href="http://www.flickr.com/photos/victorhu_cn/4886299611/" title="Flickr 上 凝云幻龙 的 4"><img src="http://farm5.static.flickr.com/4114/4886299611_75c650c117.jpg" width="500" height="225" alt="4" /></a></p>
<p><a href="http://www.flickr.com/photos/victorhu_cn/4886901644/" title="Flickr 上 凝云幻龙 的 5"><img src="http://farm5.static.flickr.com/4134/4886901644_47e05c0de2.jpg" width="448" height="262" alt="5" /></a></p>
<p><strong>至此，Andorid的开发环境安装成功</strong></p>
<p><strong>Step 7 : 导入Sample</strong><br />
1、新建工程，选择&#8221;Android Project&#8221;（如下图）<br />
<a href="http://www.flickr.com/photos/victorhu_cn/4886901194/" title="Flickr 上 凝云幻龙 的 6"><img src="http://farm5.static.flickr.com/4115/4886901194_0dea6c540b.jpg" width="500" height="378" alt="6" /></a><br />
2、在&#8221;Contents&#8221;中选择&#8221;Create project from existing source&#8221;，<br />
在&#8221;Location&#8221;中选择Samples的文件夹，这里选择&#8221;&lt;android_sdk&gt;/samples/android-7/Home&#8221;<br />
在&#8221;Build Target&#8221;中选择开发平台，这里选择&#8221;Android 2.2&#8243;（截图如下）<br />
<a href="http://www.flickr.com/photos/victorhu_cn/4886299479/" title="Flickr 上 凝云幻龙 的 7"><img src="http://farm5.static.flickr.com/4074/4886299479_2bb21ea18b.jpg" width="414" height="500" alt="7" /></a></p>
<p><strong>Step 8 : 新建AVD（Android Virtual Device）</strong><br />
在Eclipse中选择&#8221;Windows&#8221; &#8211;> &#8220;Android SDK and AVD manager&#8221;，在左侧选择&#8221;Virtual Devices&#8221;，然后选择右侧的&#8221;New&#8221;（截图如下）<br />
<a href="http://www.flickr.com/photos/victorhu_cn/4886901466/" title="Flickr 上 凝云幻龙 的 8"><img src="http://farm5.static.flickr.com/4095/4886901466_b3fc3ebcac.jpg" width="500" height="266" alt="8" /></a><br />
相关设置:<br />
1、Name，任意但有限制，不可以有空格、点等一些特殊字符<br />
2、Target，需要和刚才选择的&#8221;Build Target&#8221;一致<br />
3、SD Card，设定给Android分配的SD卡内存容量，这里选择1G（1024MB）<br />
其他的默认即可（截图如下）<br />
<a href="http://www.flickr.com/photos/victorhu_cn/4886901342/" title="Flickr 上 凝云幻龙 的 9"><img src="http://farm5.static.flickr.com/4136/4886901342_bba6a6edc0.jpg" width="365" height="500" alt="9" /></a></p>
<p><strong>Step 9 : 运行</strong><br />
找到运行按钮，或者直接Ctrl＋F11，稍微等待一下编译过程，然后即可出现Android的运行界面，附截图两枚<br />
<a href="http://www.flickr.com/photos/victorhu_cn/4886901422/" title="Flickr 上 凝云幻龙 的 10"><img src="http://farm5.static.flickr.com/4095/4886901422_b5a8940284.jpg" width="500" height="338" alt="10" /></a></p>
<p><a href="http://www.flickr.com/photos/victorhu_cn/4886299565/" title="Flickr 上 凝云幻龙 的 11"><img src="http://farm5.static.flickr.com/4077/4886299565_2404f85676.jpg" width="500" height="338" alt="11" /></a></p>
<p><strong>至此，所有工作基本完成，有了Documentation、Samples，Android的大门已经打开了！</strong></p>
<p>参考资料：<br />
1、<a href="http://developer.android.com/sdk/installing.html" target="_blank">Installing the SDK | Android Developers</a><a><br />
2、《</a><a href="http://book.douban.com/subject/4706090/" target="_blank">Android应用程序开发</a>》</android_sdk></p>
]]></content:encoded>
			<wfw:commentRss>http://huxuan.org/20100813/install_android_development_environment_on_ubuntu_10_04/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

