<div id='blogs'></div>
<xml id=xslt>
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/methodResponse/params/param/value/array/data">
<xsl:for-each select="value/struct">
<div style="background:#EEEEEE"><a href="{member[6]/value/string}" target="_blank"> <xsl:value-of select="member[3]/value/string"/></a> <xsl:value-of select="member/value/dateTime.iso8601"/></div>
<div><xsl:value-of select="member[2]/value/string" disable-output-escaping="yes" /></div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</xml>
<script language="javascript">
MetaWeblog = function(methodName,rsFunction)
{
this.fnResult = rsFunction;
var methodname = methodName;
var ptext = '';
this.Add = function(v,tp) {
if (!tp) tp='string';
ptext += "<param><value><" +tp+ ">"+ v +"</"+tp+"></value></param>";
}
this.GetParamsText = function() {
return '<?xml version="1.0"?><methodCall><methodName>'+methodname+"</methodName><params>"+ptext+"</params></methodCall>";
}
this.clear = function() {
ptext = '';
}
}
function $(id) { return document.getElementById(id); }
function getUsersBlogs()
{
var blogid = new MetaWeblog('blogger.getUsersBlogs',rsgetUsersBlogs);
blogid.Add('123456798');
blogid.Add($('username').value);
blogid.Add($('password').value);
GetResponseXML(blogid);
}
function rsgetUsersBlogs(oXml)
{
var node = oXml.selectSingleNode('/methodResponse/params/param/value/array/data/value/struct/member/value/string');
$('blogid').value = node.text;
}
function getRecentPosts()
{
var blog = new MetaWeblog('metaWeblog.getRecentPosts',rsgetRecentPosts);
blog.Add($('blogid').value);
blog.Add($('username').value);
blog.Add($('password').value);
blog.Add($('getcount').value,'int');
GetResponseXML(blog);
}
function rsgetRecentPosts(oXml)
{
var txt = oXml.transformNode(xslt.documentElement);
$('blogs').innerHTML = txt;
}
var xmlhttp ;
function GetResponseXML(MWeblog)
{
var metaWeblog = MWeblog;
load.style.display='';
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.onreadystatechange = function() {
window.status += xmlhttp.readyState+' ';
if(xmlhttp.readyState == 4)
{
load.style.display='none';
window.status = '获取数据结束。';
if(xmlhttp.status == 200)
{
var xmlReturn = xmlhttp.responseText;
$("gttext").value=xmlReturn;
metaWeblog.fnResult(xmlhttp.responseXML);
}
else
{
alert("出现错误:\n"+xmlhttp.statusText+"\n"+xmlhttp.status);
}
xmlhttp = null;
}
}
//var murl = 'http://pharaoh.cnblogs.com/services/metablogapi.aspx';
var murl='http://'+$('username').value+'.cnblogs.com/services/metablogapi.aspx'
xmlhttp.Open("POST",murl,true);
var sendText = metaWeblog.GetParamsText();
$('sdtext').value = sendText;
xmlhttp.Send(sendText);
window.status = '开始获取...';
}
</script>