Injecting an XML document contents into a HTML table

That’s correct, but unhelpful. It’s this section of code that isn’t right.

$.ajax({
  type: "GET",
  url: "productXmlStructure.xml",
  dataType: "xml",

  ....

Best to create a function to handle the response xml.

var receivedXML = function(resp) {
  console.log(resp);
}

$.ajax({
  type: "GET",
  url: "productXmlStructure.xml",
  dataType: "xml",
  success: receivedXML
})

Try running this code and then looking at the response in the console.

This part of code isn’t correct either, parseXML isnt’ expecting a url of an xml document, it’s expecting a string of XML like <tag><a><b>blah</b></a></tag>

var XML = 'productXmlStructure.xml'
var xmlParsed = $.parseXML(XML);

Because you’re using dataType: ‘xml’, jQuery will already be parsing the returned XML string from the response into a parsed XML document. So, in the first function at the top resp should be an XML document that you can search through.

2 Likes