javascript - Get data from XML and display in a DIV -
i'm trying display xml data text. i'm using javascript getting image data , works fine couldn't manage display text data.
here xml:
<vector> <pic> <ad>01-wedding.jpg</ad> <txt>1</txt> <met>tasarim 1</met> </pic> </vector>
here javascript:
<script type="text/javascript"> if (window.xmlhttprequest) {xmlhttp=new xmlhttprequest();} else{xmlhttp=new activexobject("microsoft.xmlhttp");} xmlhttp.open("get","resimler.xml",false); xmlhttp.send(); xmldoc=xmlhttp.responsexml; x=xmldoc.getelementsbytagname("pic"); i=0; function displayfoto(){ ad=(x[i].getelementsbytagname("ad")[0].childnodes[0].nodevalue); txt=(x[i].getelementsbytagname("met")[0].childnodes[0].nodevalue); document.getelementbyid("showfoto").src="img/" + ad; document.getelementbyid("metintext").value=txt;} function next(){ if (i<x.length-1){ i++; displayfoto();}} function previous(){ if (i>0){ i--; displayfoto();}} </script>
and here div:
<div id="container"> <div class="inner-tasarim"> <div id="slideshow"> <ul class="slides"> <li><img id='showfoto'/></li> </ul> <span class="arrow previous"><img onclick="previous()" src="img/arrow-prev.png"> </span> <span class="arrow next"><img onclick="next()" src="img/arrow-next.png"></span> <span class="metinalani"><h2 id='metintext'></h2></span> </div> </div> </div>
what doing wrong?
Comments
Post a Comment