Micle Micle - 1 month ago 5
Javascript Question

where I must to put my xml files which I want to use it in my dynamic web project on eclipse?

I new with xml I read tutorial on (w3schools.com) on xml file I find sample to read and print an xml file this code:

<p id="demo"></p>

var xhttp;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
xhttp.open("GET", "books.xml", true);

function myFunction(xml) {
var x, i, txt, xmlDoc;
xmlDoc = xml.responseXML;
txt = "";
x = xmlDoc.getElementsByTagName("title");
for (i = 0; i < x.length; i++) {
txt += x[i].childNodes[0].nodeValue + "<br>";
document.getElementById("demo").innerHTML = txt;

But I don't knew where I must to put my xml file on my dynamic web project on eclipse ?
in code above the instruction
xhttp.open("GET", "books.xml", true);

where I must to put books.xml file ?


It purely depends how you do the configuration, but i will provide some ways in which you can follow-

1) You can directly put the xml files inside your webcontent folder.

enter image description here
2) If you have more number of XML files and you want them to according to there type in one place then you can store it inside some folder <folder-name> inside webcontent.enter image description here

for the second scenario you have to slightly modify the code you are trying to run as below xhttp.open("GET", "data/books.xml", true);