309

As far as XML parsing is concerned, which is the best node module, that I can use for XML parsing?

0

2 Answers 2

228

You can try xml2js. It's a simple XML to JavaScript object converter. It gets your XML converted to a JS object so that you can access its content with ease.

Here are some other options:

  1. libxmljs
  2. xml-stream
  3. xmldoc
  4. cheerio – implements a subset of core jQuery for XML (and HTML)

I have used xml2js and it has worked fine for me. The rest you might have to try out for yourself.

Sign up to request clarification or add additional context in comments.

6 Comments

libxmljs allows traversing the xml with commands like .find(), really useful.
xml-stream worked for me very well. It's especially convenient when receiving XML data from a remote server.
xml2js has worked very nicely for me
xml-stream doesn't work well with windows. Use xml-flow! github.com/matthewmatician/xml-flow
For what it's worth xml-js is very nice too. It has methods for XML to JS and vice versa, as well as XML to JSON and vice versa.
|
151

This answer concerns developers for Windows. You want to pick an XML parsing module that does NOT depend on node-expat. Node-expat requires node-gyp and node-gyp requires you to install Visual Studio on your machine. If your machine is a Windows Server, you definitely don't want to install Visual Studio on it.

So, which XML parsing module to pick?

Save yourself a lot of trouble and use either xml2js or xmldoc. They depend on sax.js which is a pure Javascript solution that doesn't require node-gyp.

Both libxmljs and xml-stream require node-gyp. Don't pick these unless you already have Visual Studio on your machine installed or you don't mind going down that road.

Update 2015-10-24: it seems somebody found a solution to use node-gyp on Windows without installing VS: https://github.com/nodejs/node-gyp/issues/629#issuecomment-138276692

12 Comments

@rainabba That's why I wrote: This answer concerns developers for Windows. On Windows VS is required.
@rainabba I wish quoting the first sentence of the node-gyp git repo makes it all okay. You clearly have not been plagued with node-gyp issues on window.
wish i read this before trying to use xml-stream, couple of hours lost on trying to get node-gyp to work
If your machine is a Windows Server, you definitely don't want to install Visual Studio on it. Can anyone explain this statement?
Visual Studio is a fairly heavy weight development tool, you don't usually want to install (and license) development tools, on production servers.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.