I have proxied an S3 call through my Node.js server and want to configure only a couple of returned XML values โโbefore they are maximized. With the exception of these settings, I would like to save the rest of each answer, for example. response headers.
I can, of course, first collect the whole answer, parse the XML, convert it and return it, but for large answers that will be slow and memory intensive. Is there a way that I can achieve basically stream.pipe() , but maybe with a conversion function?
I looked at sax-js , which may work, but does not have the ability to convert. Should I resort to listening to low-level parsing events and generating and outputting the resulting XML file?
I also looked at libxmljs , which has a โparserโ and a higher level DOM API, but it looks like I have to listen to parsing events myself again at a low level, and I'm not sure if I can pass the resulting XML result via least of its creation.
Is there an easier way than either of these two approaches? Thanks!
PS XML settings are simple: just remove the substring from some text elements.
source share