Im trying to run this javascript on my site but I can't seem to get it to load. I followed the tutorial link below but it just doesn't seem to load properly. Can anyone help. Sorry I'm new to working with XML.
Im also trying to run this locally, not on a server.
Video Link: https://www.youtube.com/watch?v=ppzYGd0wi_c
<!DOCTYPE html>
<html>
<head>
<title>XML Testing</title>
<meta name=viewport content="width=device-width, initial-scale=1">
<!-- CSS Style Information -->
<!-- <link rel="stylesheet" href="files/style.css" media="all">-->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type: "GET",
url: "data.xml",
dataType: "xml",
success: xmlParser
});
});
function xmlParser(xml){
$(xml).find("painting").each(function){
$("#container").append('<div class="painting"><img src="images/' + $(this).find("image").text() + '" width="200" height="225" alt="' + $(this).find("title").text() + '" /><br/><div class="title">' + $(this).find("title").text() + '<br/>$' + $(this).find("price").text() + '</div></div>');
});
}
</script>
</head>
<body id="body">
<div id="container">
</div>
</body>
</html>
Separate xml file called data.xml
<?xml version="1.0"?>
<paintings>
<painting>
<title>Boardwalk 5</title>
<artist>Arnie Palmer</artist>
<image>test.png</image>
<price>850</price>
</painting>
<painting>
<title>Boardwalk 5</title>
<artist>Arnie Palmer</artist>
<image>test.png</image>
<price>850</price>
</painting>
</paintings>