RSS 埋め込み
<?php $url = "feedのURL"; $xml = file_get_contents($url); header("Content-type: application/xml; charset=UTF-8"); print $xml;
<body> <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js'></script> <script type="text/javascript"> $(function() { $.ajax({ url: 'rss.php', xmlType: 'xml', success: function(xml) { var row = 0; var data = []; var nodeName; var output = $('#rssArea'); $(xml).find('item').each(function() { data[row] = {}; $(this).children().each(function() { nodeName = $(this)[0].nodeName; data[row][nodeName] = {}; attributes = $(this)[0].attributes; for (var i in attributes) { data[row][nodeName][attributes[i].name] = attributes[i].value; } data[row][nodeName]['text'] = $(this).text(); }); row++; }); output.wrapInner('<ul></ul>'); // すべて表示する場合は for (i in data) for (i=0; i<=4; i++ ) { output.find('ul').append('<li><a target="_blank" href="' + data[i].link.text + '">◇ ' + data[i].title.text + '</a>' + '</li>'); // console.log (data[i]); } } }); }); </script> <div id="rssArea"></div> </body> </html>