0

I am trying to do very basic XML. I am very green in this and need some help in this. I am trying to show my XML file in a simple HTML page just like the w3 website --> http://www.w3schools.com/xml/tryit.asp?filename=tryxml_display_table

However when I am changing all my elements it still showing nothing. Below is some code snippets of my XML and html file.

Part of my XML File

<recipe_list>
<recipe>
<name>Pizza</name>
<description>Capricciosa</description>
<course>Main</course>
<servings>1</servings>
<ingredients>

Part of my HTML, I am using the w3schools website as shown above.

xmlhttp.open("GET","task1-recipe.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 

document.write("<table><tr><th>Name</th><th>Description</th><th>Course</th>  <th>Servings</th></tr>");
var x=xmlDoc.getElementsByTagName("recipe");
for (i=0;i<x.length;i++)
  { 
 document.write("<tr><td>");
 document.write(x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);

Console Error

XMLHttpRequest cannot load file:///C:/Users/Mark/Desktop/task1-recipe.xml. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.(anonymous function) @ task5-recipe.html:25 task5-recipe.html:25 Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/Users/Mark/Desktop/task1-recipe.xml'.

Mark Fenech
  • 1,358
  • 6
  • 26
  • 36

0 Answers0