In my previous post Processing Large XML Data Feeds With Node.js I gave an example of calling a SOAP webservice then writing the response XML to file. I then used the xml-stream module to parse through the xml and create a CSV/TSV file. At the time I originally tried streaming directly from the http request to xml-stream but was getting an error.
I have been going through the stream-adventure workshop from NodeSchool.io. I recomend it as a great introduction into using streams in Node.js. I feel I now have a better understanding of streams in Node.js. I thought I would take another crack at piping the http response directly to xml-stream. As it turns out it was much simpler than I thought. Since the the request module itself returns a node stream, all I had to do was pass it into the xml-stream module. It worked great and was much faster than my previous program. See the full example below.