Click here to Skip to main content
16,020,990 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:


Im new to javascript and i need to produce a scrolling type display in a div tag within my html page by getting content from a xml file. I'm not able to get how i can create a interval between the display of each section and how to get it into this div tag in paragraph form.
Please help me out..

abc.xml

XML
<projects>

<project>
    <flag>1</flag>
    <name>Project 1</name>
    <descp> Short description. </descp>
    <rating> 6 </rating>
    <link> URL1 </link>
    </project>

<project>
    <flag>1</flag>
    <name>Project 2</name>
    <descp> Short description. </descp>
    <rating> 9 </rating>
    <link> URL2 </link>
    </project>

<project>
    <flag>1</flag>
    <name>Project 3</name>
    <descp> Short description. </descp>
    <rating> 4 </rating>
    <link> URL3 </link>
    </project>

<project>
    <flag>1</flag>
    <name>Project 4</name>
    <descp> Short description. </descp>
    <rating> 5 </rating>
    <link> URL4 </link>
    </project>

</projects>


Posted

1 solution

C#
var xmlDoc;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
            xmlhttp.open("GET", "abc.xml", false);
            xmlhttp.send();
            xmlDoc = xmlhttp.responseXML;


flag = xmlDoc.getElementsByTagName("flag");
name = xmlDoc.getElementsByTagName("name");
descp = xmlDoc.getElementsByTagName("descp");
rating = xmlDoc.getElementsByTagName("rating");
link= xmlDoc.getElementsByTagName("link");


-=-=-=-=-=-=--=--=-=-=-=-=-=-=--=--=-=-=-=-=-=-=--=--=

then you have an array by using that array you can display xml content in html page
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900