<?xml version ="1.0" encoding = "UTF-8"?>
<!-- this a comment -->
<employees>
<employee id ="1">
<first_name> john </first_name>
<last_name> Devon </last_name>
<date_of_joining>
<day>12</day>
<month>1</month>
<year>2014</year>
</date_of_joining>
<department role="the Manager">sales</department>
</employee>
</employees>
<html>
<head>
<script>
var xmlObject, docObject, name, dateofJoining
xmlObject = new XMLHttpRequest();
xmlObject.open("GET","employees.xml",false);
xmlObject.send();
docObject = xmlObject.responseXML;
name = docObject.getElementByTagName("first_name")[0].childNodes[0].nodeValue;
document.write("Name = "+name+ </BR>");
dateofJoining = docObject.getElementByTagName("day")[0].childNodes[0].nodeValue;
dateofJoining = dateofJoining +"/"+docObject.getElementByTagName("month")[0].childNodes[0].nodeValue;
dateofJoining = dateofJoining +"/"+docObject.getElementByTagName("year")[0].childNodes[0].nodeValue;
document.write("DateofJoining= "+dateofJoining+"<BR/>");
</script>
</head>
<body>
</body>
</html>
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY
JS-XML2.html
Open in new window
employees.xml
Open in new window