أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
please show me what your function elements mean ?
can I use Google Drive or Dropbox to share that XML file and connect it to any HTML file at any place or web server ?
You can do that by creating XMLHttpRequest Object, first make an xml file and define your tags or data.
Then use the following code in javascript to make a call to the server
xmlhttp=new XMLHttpRequest(); //XMLHttpRequest Object
xmlhttp.open("GET","XML_FILE_NAME",false); //Replace your xml filename at this line
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
Once you get the data you can use document.write() function to create table and loops to display them inside the table like this:
document.write("<table><tr><th>TABLE_HEAD_1</th> <th>TABLE_HEAD_2</th></tr>");
var x=xmlDoc.getElementsByTagName("TAG_NAME");
for (i=0;i<x.length;i++) {
//YOUR CODE TO DISPLAY CHILD NODES OF THE TAG DEFINED IN XML FILE
}
document.write("</table>");
Yes you can use your xml as database but you will need an ajax and/or http call through JS, here is an example:
<table id="demo"></table><script>function loadXMLDoc() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState ==4 && xmlhttp.status ==) { myFunction(xmlhttp); } } xmlhttp.open("GET", "YOUR_XML_URL", true); xmlhttp.send();}function myFunction(xml) { var i; var xmlDoc = xml.responseXML; var table="<tr><th>Artist</th><th>Title</th></tr>"; var x = xmlDoc.getElementsByTagName("CD"); for (i =0; i <x.length; i++) { table += "<tr><td>" + x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue + "</td><td>" + x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue + "</td></tr>"; } document.getElementById("demo").innerHTML = table;}</script>