IT STUDENT
Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Create a new XML element

Go down  Message [Page 1 of 1]

1Create a new XML element Empty Create a new XML element Thu Oct 24, 2013 10:56 am

Admin


Admin

<!DOCTYPE html>
<html>
<body>
<script>
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","books.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

newel=xmlDoc.createElement("edition");
newtext=xmlDoc.createTextNode("First");
newel.appendChild(newtext);
x=xmlDoc.getElementsByTagName("book");
x[0].appendChild(newel);

for (i=0;i<x[0].childNodes.length;i++)
{
if (x[0].childNodes[i].nodeType==1)
{
document.write(x[0].childNodes[i].nodeName);
document.write(": ");
document.write(x[0].childNodes[i].childNodes[0].nodeValue);
document.write("<br>");
}
}
</script>
</body>
</html>

https://itstudent-pnv.board-directory.net

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum