What is the correct way to read an XML file using JavaScript, and how can I extract values from each "marker" element?

If you’re working in a modern browser environment, this is a clean and promise-based way to do it:

fetch('markers.xml')
  .then(response => response.text())
  .then(str => {
    const parser = new DOMParser();
    const xml = parser.parseFromString(str, "application/xml");
    const markers = xml.getElementsByTagName("marker");

    for (let i = 0; i < markers.length; i++) {
      const type = markers[i].getElementsByTagName("type")[0].textContent;
      const title = markers[i].getElementsByTagName("title")[0].textContent;
      const address = markers[i].getElementsByTagName("address")[0].textContent;
      console.log(type, title, address);
    }
  });