How to work with XML in javascript?

So, in Javascript, I work a lot with json.

This is simple as it looks like a js object. So all I need to do when getting json back from an HTTP request is to parse it to a js object. When I want to send the js object as json, I build it.

But some APIs just return XML.

How do I interact with XML? Am I parsing it with an object with XMLtoObject lib? Is there a built-in method in js?

Or am I using the xpath / css selector to get what I want on this line? How to add items, etc.

Hope someone can shed some light on this topic.

Hooray!

+3
source share
3 answers

Sarissa, , XML-. XPATH, XSLT, .

, .

+1

HTML W3C DOM, , , HTML-.

+2

You parse XML with an XML parser. All modern browsers have one built-in, but working with it is not entirely trivial, nor cross-platform. See ww3schools for a quick guide to get you started.

+1
source

All Articles