title: How to transform (simple) streaming XML in Node.js?
body: <p>I'm proxying an S3 call through my Node.js server and want to tweak just a couple of the returned XML values before proxying them. Except for those tweaks, I'd like to maintain the rest of each response, e.g. the response headers.</p>
  <p>I can of course gather the whole response first, parse the XML, transform it, and return it back, but for large responses that'll be both slow and memory-intensive. Is there a way I can achieve basically a <strong><code>stream.pipe()</code></strong> but with maybe a transformation function?</p>
  <p>I've looked at <strong><a href="https://github.com/isaacs/sax-js" rel="nofollow noreferrer">sax-js</a></strong>, which can pipe but doesn't have any transform ability. Do I have to resort to listening to low-level parse events and generating and outputting the resulting XML myself?</p>
  <p>I've also looked at <strong><a href="https://github.com/polotek/libxmljs" rel="nofollow noreferrer">libxmljs</a></strong> which has a &quot;push parser&quot; and a higher-level DOM API, but it looks like I'd again have to listen to low-level parse events myself, plus I'm not sure I can stream the resulting XML <em>out</em> as it's generated.</p>
  <p>Is there any easier way than either of these two approaches? Thanks!</p>
  <p>P.S. The XML tweaks are simple: just removing a substring from some text elements.</p>