round-tripping xml to javascript objects without losing data or corrupting it

I need to get some XML, convert it to javascript, muck around with it, and convert it back to XML. I'm working in Node.js.

Currently, if I round trip it from XML to Javascript objects, then back to XML, I end up with a bunch of characters that are screwy (an apostrophe might look like this: ’ , for example), and CDATA sections are lost.

I've been using xml2js module (also tried xml2js-expat) to read the xml. The xml labels itself as being UTF-8, and I specify this to xml2js.

To convert back to XML, I am using this: http://goessner.net/download/prj/jsonxml/json2xml.js

But it appears the problem is with the first step.

Any solutions to this?