Below are the file location and loading of each of the CSS and JS filename.
<link href="css/default.css" rel="stylesheet" />
<script src="js/main.js"></script>
In XML the filename is entered as such?
let data = "";
let url = 'xml/emailtext.xml';
fetch(url).then(response => response.text()).then(data => {
let parser = new DOMParser();
let doc = parser.parseFromString(data, 'application/xml');
});
In JSON?
let strfy = JSON.Stringify('json/file.json');
let json1 = JSON.parse('strfy');
When reading a json file, you can read the stream with response.json() instead of response.text(). It returns a promise that will resolve to a javascript object or array if the file contains valid json.
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response => response.json())
.then((obj)=>
{
console.log(typeof obj); // object (not json anymore)
console.log(obj);
});
obj above is not json; by then it has already been parsed into a javascript object.