I apologize to ask a question relating to this topic as it seems there are many, many topics relating to the same subject. I've read through a fair amount of them but I have not been able to find the problem with my code. I have an XML file, and I'm trying to just read a child node of each attribute (if that's the right terminology?).
The XML:
<movement>
<name>Squat</name>
<set>
<weight>270</weight>
<reps>5</reps>
</set>
</movement>
My code is just attempting to read the name attribute of each movement.
The javascript:
$(document).ready(function()
{
$.ajax({
type: "GET",
url: "/training.xml",
dataType: "xml",
success: parseXml
});
});
function parseXml(xml)
{
$(xml).find("movement").each(function()
{
$("#training").append($(this).find("name").text() + "<br>");
});
}
I found this via a tutorial online and attempted to modify it just to add the name of each movement to a div on the page. Currently it is not displaying anything. I cannot see the issue. Any help would be appreciated.
Full XML file: pastebin.com/rthMWNhm
Full HTML file: pastebin.com/6m9rBjRn