JavaScript Tip: Loading XML Data Using Fetch

preview_player
Показать описание
Loading XML data using JavaScript is still a pretty common task. We will look at how to do this using the fetch API. We will then parse the data to a format that is then accessible.

Would you like to help keep this channel going?

For more resources on JavaScript:

Courses offered on Udemy: Getting Started or Advanced Topics at a huge discount:

New Mastering Regular Expressions in JavaScript:

Tutorials referred to in this video:

#javascript #AllThingsJavaScriptLLC
Рекомендации по теме
Комментарии
Автор

Couldn't get the stackoverflow answers to work, but your tutorial did the trick! Thank you!

michaeljoel
Автор

thanks this video is really useful, just what i've looking for

TechBleND
Автор

Thank you for this tutorial! Liked and Subbed. I didn't want to set up my own server to get around the CORS issue. I tried adding `mode: "no-cors"` (parameter? setting?) to the fetch (function? object?) but I couldn't get that to work. I also tried prepending the cors-anywhere url to my xml url (you can find info on this on github) but the Heroku app that cors-anywhere uses tracks incomming traffic and will only allow 60 requests per hour. So there were apparently more than 60 requests from CodePen ... which meant it didn't work for me. For my third approach I used a Chrome extension called "Allow CORS: Access-Control-Allow-origin". That fixed the CORS issue for me and got me up and running on CodePen. One downside, if someone else tries to load my pen it won't run for them (they would have to have the Allow Cors plugin or something similar, and enable it). So if anyone knows an easy approach to get CORS working (besides setting up my own server) I'd love some advice. Thanks again for a great video!

tylery
Автор

this might be useful (you still might need to run a local server like live-server in VSCode)
.then(blob => blob.text())
.then(data => console.log(data))

rossgeography
Автор

Does it works with an XML file which is 5600 pages long ? And being loader from a website?

ParaZumir
Автор

What about fetching an uploaded file? I create a button that allows user to upload file(s), then I store them in an array-like variable called fileList. So, when I want to get data from the first file of it (fileList [0]), how can I code??? Looking forward to your help. Thank you very much

trananhome
Автор

Thank you! But is there a way we can read a xml file sent in a request. That is when you upload an xml from the client side

rajkiranm
Автор

Thanks for this great tutorial. One question remains: Is there a way to call the variable xmlDoc outside the function? I tried to declare the variable before the function, but without success.

mikunea
Автор

Is it possible to make a video for handling inconsistent json using javascript. or How to know that some problem is getting caused by inconsistent json data...

prabhatjena
Автор

Kindly sir tell me how to display xml data in a tree view form?

bintesaadat
Автор

So if it is not a local, can i just link to the https link?

mostlycraft