From the course: XML Essential Training

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Loading XML from an external source

Loading XML from an external source

From the course: XML Essential Training

Loading XML from an external source

- [Instructor] I mentioned earlier in the chapter that XML data is usually loaded from an external data source. So let's take a look at how to accomplish that. Let's open up DOM load in our editor, and it's basically the same example as we saw earlier in the course, except if we scroll down, you'll notice that there's no XML tag with data embedded in the webpage. I have a file named businesscard.XML that contains the data and we're going to build the code to load this file and construct an XML document from it. Then I'm going to call the same function we saw earlier in the chapter, which is this display business card data to display the name and email information that's coming from the loaded data. So first, let's write the function to load the XML from the file, and that's going to be this function, load XML doc. I'm going to use the fetch function that's built into the browser to retrieve the contents of the XML document. And since this function is asynchronous, you can see right…

Contents