enyo / node-tvdb

A node library for thetvdb.com
26 stars 12 forks source link

xml2js v0.2 new defaults break module #8

Closed schaze closed 11 years ago

schaze commented 11 years ago

With xml2js v0.2 new parser defaults were introduced which break the module.

"... In 0.2 we changed some defaults to parse the XML in a more universal and sane way. So we disabled normalize and trim so xml2js does not cut out any text content. You can reenable this at will of course. A more important change is that we return the root tag in the resulting JavaScript structure via the explicitRoot setting, so you need to access the first element. This is useful for anybody who wants to know what the root node is and preserves more information. The last major change was to enable explicitArray, so everytime it is possible that one might embed more than one sub-tag into a tag, xml2js >= 0.2 returns an array even if the array just includes one element. This is useful when dealing with APIs that return variable amounts of subtags. ..."

see https://github.com/Leonidas-from-XIV/node-xml2js

This can easily be fixed by setting the options explicitly in the xmlParser member:

    xmlParser = new (require("xml2js")).Parser({
        trim:true,  // Remove whitespaces
        normalize:true, // Remove whitespaces
        explicitArray:false, // do not parse all fields to an array
        explicitRoot:false // we do not need the root element
    });
schaze commented 11 years ago

nevermind, I just noticed that the javascript was not up to date with the coffescript code. recompiled and all is well...