Skip to main content

Parsing XML from a fetch

  • May 12, 2020
  • 4 replies
  • 53 views

Forum|alt.badge.img+5

I’m fetching XML data text() but am running into a dead end when trying to find a way to parse the data. I tried using domparser and a few different functions I found on StackOverflow but most seem to require a non-native library. Does anyone have any suggestions on either how to parse XML in vanilla javascript or how to convert XML into JSON?

For reference when using

let parser = new DOMParser();

I get “ReferenceError: DOMParser is not defined”

4 replies

Forum|alt.badge.img+19
  • Inspiring
  • 351 replies
  • May 12, 2020

maybe try a simple function like this:


Forum|alt.badge.img+5
  • Author
  • Known Participant
  • 11 replies
  • May 13, 2020

That worked for me once I realized it was parsing it into an object where I could use keys to get what I need. Thanks!


  • New Participant
  • 2 replies
  • September 23, 2020

maybe try a simple function like this:


I found that this function doesn’t always parse data from the XML correctly, especially if there are characters like ‘<’ in the data itself.

Do you have any other recommendations on how to parse XML using another method?


Andy_Cloke
Forum|alt.badge.img+17
  • Known Participant
  • 91 replies
  • October 24, 2022

I found that this function doesn’t always parse data from the XML correctly, especially if there are characters like ‘<’ in the data itself.

Do you have any other recommendations on how to parse XML using another method?


For anyone from Google, you can try using the free Data Fetcher extension to import a remote XML file to Airtable.