Hello, I've been trying for some days, but with no success, just get the url of the xml
image below with javascript
, XML
this feed de noticias
, to list in another area the newest posts.
<media:content url="http://blog.site.com.br/wp-content/uploads/2014/09/seo-150x150.jpg" width="150" height="150" medium="image" type="image/jpeg"/>
I was able to get the Wordpress
, but the image inside a title e o link do xml
is difficult, I tried in many ways and lastly I tried that way.
var media = entry['media:content'];
Code JS
dataNovo=new Date();
dataNovo.setDate(dataNovo.getDate()-10);
function loaded_feed_blog(result) {
if (!result.error) {
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var dataPubli = new Date(entry.publishedDate);
var media = entry['media:content']; //Aqui minha dificuldade
var div = "<div class='media'><a class='pull-left' href='" + entry.link + "' target='_blank'><img class='media-object' src='" + media + "' /></a><div class='media-body'><a href='" + entry.link + "' target='_blank' title='" + entry.title + "'><h4 class='media-heading'><span class='text'>" + truncar_texto(entry.title, 100) + "</span>";
if (dataPubli > dataNovo) {
div += "<span class='label label-success'>Novo</span>";
}
div += "<small> - " + formatar_data(dataPubli) + "</small></h4>" + truncar_texto(entry.contentSnippet, 120) + "</a></div></div>";
$('.changelog-container .box-content').append(div);
}
}
}
XML
<item>
<title>SEBRAE e os Negócios</title>
<link>
http://blog.site.br/negocios-virtuais/
</link>
<comments>
http://blog.site.br/negocios-virtuais/#comments
</comments>
<pubDate>Tue, 30 Sep 2014 18:16:07 +0000</pubDate>
<dc:creator>
<![CDATA[ Shopping ]]>
</dc:creator>
<category>
<![CDATA[ Comércio Eletrônico ]]>
</category>
<category>
<![CDATA[ Produtividade ]]>
</category>
<guid isPermaLink="false">http://blog.site.com.br/?p=262</guid>
<description>
<![CDATA[
<p>Normalmente é assim, pelo menos na internet.....</p>
]]>
</description>
<wfw:commentRss>
http://blog.site.br/negocios-virtuais/feed/
</wfw:commentRss>
<slash:comments>0</slash:comments>
<media:content url="http://blog.site.com.br/wp-content/uploads/2014/09/seo-150x150.jpg" width="150" height="150" medium="image" type="image/jpeg"/>
</item>
EDIT:
To make namespace
and chamada
below:
<script src="http://www.google.com/jsapi"type="text/javascript"></script>
<script>
function OnLoad() {
var feed = new google.feeds.Feed("http://blog.site.com.br/feed/");
feed.setNumEntries(5);
feed.load(loaded_feed_blog);
}
google.load("feeds", "1");
google.setOnLoadCallback(OnLoad);
</script>
HTML
<div class="row changelog-itens">
<div class="box changelog-container alpha">
<div class="box-header">
<h2 class="pull-left">Direto do BLOG</h2>
<div class="box-widget pull-right">
<a href="http://blog.site.com.br/" target="_blank" class="btn btn-link" style="font-size: 13px; margin: 4px -10px 0 0;">Ver mais</a>
</div>
</div>
<div class="box-content"></div>
</div>
</div>
How can uso a função
below, is listing right, but ver na imagem