Need Help: Creating Simple HTML to Extract Information from XML File – Any Tips or Examples?

18 Replies, 1322 Views

Hey, noob questions are the best questions! For creating simple html to extract information from xml file, you might wanna look into using Fetch API with JavaScript.

Here’s a quick example:

```javascript
fetch("yourfile.xml")
.then(response => response.text())
.then(data => {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(data, "text/xml");
const items = xmlDoc.querySelectorAll("yourTag");
items.forEach(item => {
document.body.innerHTML += `<p>${item.textContent}</p>`;
});
});
```

This fetches the XML, parses it, and displays the content. Easy peasy!

Messages In This Thread



Users browsing this thread: 1 Guest(s)