• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

226
Views
How to insert an image in javascript when calling XML data?

I have data in an XML and I want to display it in a table in my HTML page. I can display my values, and I can even display the url of my image. I thought, I just need to add the <img> tag, but when I add the latter, I can't see anything.

function myFunction(xml) {
  var i;
  var xmlDoc = xml.responseXML;
  var table="<tr><th>Transporter</th><th>Type</th><th>Logo</th></tr>";
  var x = xmlDoc.getElementsByTagName("data");
  for (i = 0; i <x.length; i++) {
    table += "<tr><td>" +
    x[i].getElementsByTagName("transporter")[0].childNodes[0].nodeValue +
    "</td><td>" +
    x[i].getElementsByTagName("type")[0].childNodes[0].nodeValue +
    "</td><td>" + "<img src=\""
    x[i].getElementsByTagName("logo")[0].childNodes[0].nodeValue +
    "\"> </td></tr>";
  }
  document.getElementById("transporterlist").innerHTML = table;
} 

Do you think this is not possible? Thanks

almost 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error