Linking XML to HTML/JSP | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 24

Linking XML to HTML/JSP

Assuming that I have a HTML/JSP file, and an XML file containing some information which I plan to call out in the HTML file, where should I place this XML file? According to code samples online, we initialize the XML DOM object and get the contents of the XML file through a request by invoking a method of the object. Is there a method to link the XML file to the HTML document offline? Assuming that this is not feasible and I have Xampp installed, same question: Where does the XML go?

6th May 2018, 6:26 AM
Hatsy Rei
Hatsy Rei - avatar
5 Answers
+ 7
Daniel Healy I wrote the XML, which contains a bunch of information about books and articles. From what I understand, XML is basically a database in text format, so yes, you are correct that we need knowledge about its structure in order to use it. Anyway, I've successfully achieved what I originally intended. The JSP/JS XML parser will let you specify the XML file path, so where to place the XML on your local machine (when running it as a server) is not really important.
8th May 2018, 2:23 PM
Hatsy Rei
Hatsy Rei - avatar
+ 3
Maybe i m not fully understand but you can put it where you like and use relative path for request it on your server like any other resouce (CSS, js, imgs etc)
6th May 2018, 7:41 AM
KrOW
KrOW - avatar
+ 2
@Hatsy I also tried to find a code in the internet about getting/reading a XML/JSON file from a folder using only JavaScript. But there is no way JavaScript can access my files. (Because that will let hackers easily access and steal my data) So If you have a very simple php server thats enough. #Forgive me if I got your question wrong.
8th May 2018, 2:41 PM
Cyrus Ornob Corraya
Cyrus Ornob Corraya - avatar
+ 1
Alguien que me ayude, quiero aprender mas sobre etiquetas svg y path
7th May 2018, 6:23 AM
Alfonso Guerra
Alfonso Guerra - avatar
+ 1
Where did you get the XML from? XML is basically customized HTML for specific uses. It won't work if the system reading the XML does not know how to read it.
8th May 2018, 12:59 PM
Daniel Healy
Daniel Healy - avatar