javascript - Displaying Image from XML into HTML -


i have tried display following image onto html, no avail. when html loaded, displays picture icon, won't display image itself. have copied code below

thanks.

html code:

 <script> if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.open("get","test.xml",false); xmlhttp.send(); xmldoc=xmlhttp.responsexml;  document.write("<table border='1'>"); var x=xmldoc.getelementsbytagname("test"); (i=0;i<x.length;i++) { document.write(x[i].getelementsbytagname("title")[0].childnodes[0].nodevalue); var img = document.createelement("img"); img.src = x[i].getelementsbytagname("imageurl")[0].childnodes[0].nodevalue; document.write(img.src); document.body.appendchild(img); } document.write("</table>");   </script> 

xml:

<?xml version="1.0" encoding="utf-8"?> <test_group>     <test>         <title>hello world</title>         <imageurl>"cfl_175x175.png"</imageurl>     </test>  </test_group> 

try this:

<imageurl>cfl_175x175.png</imageurl> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -