Skip to content
Advertisement

XML response text is undefined

I am making a call to an external server and am getting a valid response back with data. If I dump that data into console.log() I can see the data that I’m looking for. However the returned data is XML and if I try and use the getElementsByTagName method on the response text I get the error Uncaught TypeError: searchResults.getElementsByTagName is not a function. I checked and searchResults is undefined, which I’m assuming is my problem, I’m just not sure how to fix it.

JavaScript

Advertisement

Answer

you can do like this,

JavaScript

here we are parsing the xml and getting it to the variable xmlDoc

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement