3 ms·
Ha. Honestly, you're totally right. I've used XHR for years but never actually for XML. When looking at WebDAV in the past I couldn't find a way to serialize/de
by anderspitman 4y ago
Ha. Honestly, you're totally right. I've used XHR for years but never actually for XML. When looking at WebDAV in the past I couldn't find a way to serialize/deserialize XML the same way you can with JSON (is there a way?), but I didn't realize XHR handles that natively. TIL, thanks.
- easrng 4y agoYou can use a DOMParser to parse XML (or HTML) from a string. const doc = new DOMParser().parseFromString('<xml><tag attr="value" /></xml>', "text/xml"); doc.querySelector("tag").getAttribute("attr") // returns "value"
- anderspitman 4y agoAwesome, thanks! I could have sworn I looked into this and didn't find a way in vanilla JS, but definitely looks like I was wrong.