Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- <div id="noticias">...</div>
- <script>
- //al cargar la página procesamos el RSS (XML), es necesario jQuery
- $(function() {
- //el archivo XML a procesar
- $.get("archivoRSS.xml", function(m) {
- xml = $(m);
- var botija = 'Noticias'; //variable contenedor
- xml.find("item").each(function(i) {
- var $this = $(this);
- item = {
- title: $this.find("title").text(),
- url: $this.find("link").text(),
- image: $this.find('media\\:content,content').attr('url'),
- };
- botija += '<div><a href="'+item.url+'">'+(item.image?'<img src="'+item.image+'" alt="imagen" /><br />':'')+item.title+'</a></div>';
- });
- //establecemos el contenido de $botija al nodo #noticias
- setTimeout(function() {
- $("#noticias").html(botija);
- },1000);
- },'xml');
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement