2

wordpress でホストされているブログがあり、RSS フィードを取得して、XSLT を使用して別の Web サイトに解析できるようにしたいと考えています。クライアント側で解析しようとしているので、フィードへのリンクをプラグインして、リアルタイムの更新に利用できます。

これが私のhtmlです:

<!DOCTYPE html>
<html>
    <head>
        <script>
    function loadXMLDoc(dname){
        if (window.XMLHttpRequest){
            xhttp=new XMLHttpRequest();
        }else{
            xhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }

        xhttp.open("GET",dname,false);
        xhttp.send("");
        return xhttp.responseXML;
    }

    function displayResult(){
        xml=loadXMLDoc("http://myBlog.wordpress.com/feed");
        xsl=loadXMLDoc("styles.xsl");
        // code for IE
        if (window.ActiveXObject){
          ex=xml.transformNode(xsl);
          document.getElementById("example").innerHTML=ex;
        }
        // code for Mozilla, Firefox, Opera, etc.
        else if (document.implementation && document.implementation.createDocument){
            xsltProcessor=new XSLTProcessor();
            xsltProcessor.importStylesheet(xsl);
            resultDocument = xsltProcessor.transformToFragment(xml,document);
            document.getElementById("example").appendChild(resultDocument);
        }
    }
        </script>
    </head>
    <body onload="displayResult()">
        <div id="example"/>
    </body>
</html>

そして、これが私のブログから取得しているフィードをフォーマットするために使用している私の xsl ドキュメントです。HTML ファイルを表示してもエラーは発生しませんが、ページは何も表示されていません。

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
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/"
xmlns:georss="http://www.georss.org/georss"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:media="http://search.yahoo.com/mrss/">

<xsl:template match="/">
 <html>
 <body>
<xsl:for-each select="rss/channel/item">
    <p>
        <xsl:value-of select="title"/>
    </p>
</xsl:for-each>
 </body>
 </html>
</xsl:template>

4

0 に答える 0