libxml-to-js uses the string parser method of libxmljs. Basically a modified version of the algorithm from here in order to fit the formal specifications of xml2js output.
npm install libxml-to-js
The installation of the underlying dependency, libxmljs, fails if you don't have gcc (or compatible compiler), the libxml2 development headers, and the xml2-config script. Under various Linux distributions you may install the appropriate libxml2 development package: libxml2-dev (Debian, Ubuntu, etc), libxml2-devel (RHEL, CentOS, Fedora, etc).
var parser = ;var xml = 'xml string';;
With XPath query:
Due to the fact that libxmljs does not have any method for returning the namespace attributes of a specific element, the returned namespaces aren't returned as expected:
Example from the WordPress RSS 2 feed:
<!-- the rest of the doc -->
is parsed as:
'@':version: '2.0'xmlns:atom: ''sy: ''dc: ''content: ''wfw: ''slash: ''// the rest of the doc