Span/Div help

K

karsagarwal

Hi,

I am new to javascript and would like some help. I would like to
convert the xml file (which consists of title and a description tag)
to html. Each title and description will be displayed as a layer in
the slideshow. I am having difficulty with the appropriate use of
"span" to create that layering/array set up. I am including my code
below. Any input would be really appreciated.

Thanks.


<script type="text/javascript">
var slideShowSpeed = 500;

var t;
var current=0;

function display(){

//takes 2 parameters - string that is a snippet of JS code executed
when the specified
// interval has elapsed and the 2nd is an integer that specifies # of
millisecs.
t = setTimeout('display()', slideShowSpeed);
current = current % layer.length;
document.getElementById("rotate").textContent=layer[current+
+];

//if (current == 4) current=0 else current++



}

function parseXML()
{
debugger;

var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");

}
else if (document.implementation.createDocument)
{// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
return;
}

xmldoc = new XmlDocument();
if (xmlDoc!=null)
{


xmlDoc.async=false;
xmlDoc.load("T:\Sangeeta\RSS\cnn_topstories.xml");
x=xmlDoc.getElementsByTagName("title");
for (i=0;i<x.length;i++) {
document.write(x.childNodes[0].nodeValue);
console.info(x);
document.write("<br /");
}
}


//converting xml file to html

//
document.getElementById("0").innerHTML=xmlDoc.getElementsByTagName("item")
[0].childNodes[0].nodeValue;
//
document.getElementById("1").innerHTML=xmlDoc.getElementsByTagName("title")
[0].childNodes[0].nodeValue;
//
document.getElementById("2").innerHTML=xmlDoc.getElementsByTagName("title")
[0].childNodes[0].nodeValue;
//
document.getElementById("3").innerHTML=xmlDoc.getElementsByTagName("title")
[0].childNodes[0].nodeValue;
//
document.getElementById("4").innerHTML=xmlDoc.getElementsByTagName("title")
[0].childNodes[0].nodeValue;

}


</script>
</head>

<body>
<ul>
<li><a href="#" onclick=parseXML(); return false;"> Test parseXML</
a></li>
</ul>
<!--
<div id="rotate"><p>test</p>

<p><b>Item Title:</b><span id="0"; style="position:absolute; top:0px;
left:0px; width:50px; height:50px; background-color:red;
border:solid 1px white; vidibility:hidden "></span><br />
<span id="1"; style="position:absolute; top:20px; left:20px; width:
50px; height:50px; background-color:blue; border:solid 1px white;
"></span><br />
<span id="2"; style="position:absolute; top:40px; left:40px; width:
50px; height:50px; background-color:green; border:solid 1px white;
"></span><br />
<span id="3"; style="position:absolute; top:50px; left:50px; width:
50px; height:50px; background-color:purple; border:solid 1px white;
"></span><br />
<span id="4"; style="position:absolute; top:60px; left:60px; width:
50px; height:50px; background-color:yellow; border:solid 1px white;
"></span><br />

</div>

<SCRIPT type="text/javascript">parseXML() </script>

-->
</body>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top