Hola¡
Tengo este codigo para leer un archivo XML con la idea de cargar un lector RSS de noticias:
function Replace(totalValue,oldValue,newValue)
{
while(totalValue.indexOf(oldValue) > -1)
totalValue=totalValue.replace(oldValue,newValue);
return totalValue;
}
/* Get XML Node
(Parameters) TagName:'XML Element' node:'Element row number' */
function getNode(TagName, node)
{
var currentNode = (node == null) ? xmlDoc.getElementsByTagName(TagName) :
items[node].getElementsByTagName(TagName);
if(currentNode.length > 0)
return currentNode[0].firstChild.nodeValue;
}
/* Load XML Object
(Parameters) rssFeed:'RSS File' Body:'Layer for RSS Body' Title:'Layer for RSS Title' */
function ReadRSS(rssFeed, Body, Title)
{
rssTitle = document.getElementById(Title);
rssBody = document.getElementById(Body);
try
{
if (document.all)
{
var errorHappendHere = "Check Browser and security settings";
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
}
else
{
var errorHappendHere = "Apparently one cant read remote xml via firefox, please copy the file to your server";
xmlDoc = document.implementation.createDocument("","",null) ;
}
xmlDoc.async=false;
xmlDoc.load(rssFeed);
items=xmlDoc.getElementsByTagName('item');
SetRSSTemplates();
}
catch(e)
{
rssTitle.innerHTML = 'Error occured';
rssBody.innerHTML = 'Thrown Error:'+e.message+"<br/>Note: "+errorHappendHere;
}
}
/* Set HTML Template
Did it this way to make the look and feel of the feed easy customizable, dont like mixing
layout with code. */
function SetRSSTemplates()
{
if (rssBody)
{
var buffer = "";
for(var i=0; i< items.length; i++)
{
var output = (document.all) ? Replace(rssBody.innerHTML,"(::Link::)",getNode('li nk',i))
: Replace(rssBody.innerHTML,"%28::Link::%29",getNode ('link',i));
output = Replace(output,"(::Title::)",getNode('title',i));
output = Replace(output,"(::Pubdate::)",getNode('pubDate',i ));
output = Replace(output,"(::Description::)",getNode('descri ption',i));
buffer+=output;
}
rssBody.innerHTML = buffer;
}
if (rssTitle)
{
var output = Replace(rssTitle.innerHTML,"(::Title::)",getNode(' title'));
output = (document.all) ? Replace(output,"(::Link::)",getNode('link'))
: Replace(output,"%28::Link::%29",getNode('link'));
output = Replace(output,"(::Description::)",getNode('descri ption'));
rssTitle.innerHTML = output;
}
}
Estoy teniendo un grave problema, ya que por alguna tonteria del IE me lo bloquea con la tipica ventanita amarilla de conceder permiso para ejecutar codigo script o ActiveX, esto me pasaba en local pero no me imaginaba que en el servidor me lo iva a bloquear igual.Para poder ejecutarlo tengo que agregar el sito web a sitios web de confianza.
Alguien le ha ocurrido algo parecido alguna vez, que solucion aplico para solucionarlo?¿
Un saludo ¡¡