1.2.1 • Published 10 years ago

xml-parser v1.2.1

Weekly downloads
67,000
License
MIT
Repository
github
Last release
10 years ago

xml-parser

Simple non-compiant XML parser because we just need to parse some basic responses and libxml takes forever to compile :D you probably don't want to use this unless you also have similar needs.

Installation

$ npm install xml-parser

Example

JavaScript:

var fs = require('fs');
var parse = require('xml-parser');
var xml = fs.readFileSync('examples/developerforce.xml', 'utf8');
var inspect = require('util').inspect;

var obj = parse(xml);
console.log(inspect(obj, { colors: true, depth: Infinity }));

XML:

<?xml version="1.0" encoding="utf-8"?>
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns="urn:enterprise.soap.sforce.com">
   <soapenv:Body>
      <createResponse>
         <result>
            <id>003D000000OY9omIAD</id>
            <success>true</success>
         </result>
         <result>
            <id>001D000000HTK3aIAH</id>
            <success>true</success>
         </result>
      </createResponse>
   </soapenv:Body>
 </soapenv:Envelope>

Yields:

{ declaration: { attributes: { version: '1.0', encoding: 'utf-8' } },
  root:
   { name: 'soapenv:Envelope',
     attributes:
      { 'xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
        xmlns: 'urn:enterprise.soap.sforce.com' },
     children:
      [ { name: 'soapenv:Body',
          attributes: {},
          children:
           [ { name: 'createResponse',
               attributes: {},
               children:
                [ { name: 'result',
                    attributes: {},
                    children:
                     [ { name: 'id',
                         attributes: {},
                         children: [],
                         content: '003D000000OY9omIAD' },
                       { name: 'success', attributes: {}, children: [], content: 'true' } ],
                    content: '' },
                  { name: 'result',
                    attributes: {},
                    children:
                     [ { name: 'id',
                         attributes: {},
                         children: [],
                         content: '001D000000HTK3aIAH' },
                       { name: 'success', attributes: {}, children: [], content: 'true' } ],
                    content: '' } ],
               content: '' } ],
          content: '' } ],
     content: '' } }

License

MIT

@payment-rails/afx-api-v2mcx-clientmcxclient_rreact-native-slider-kf@everything-registry/sub-chunk-3186chenyfan-blogsysadmin-notifiersync-pom-versionsync-pom-version-to-packagetenhudsvgfmtxml-escposxml-pixixml-schema2xml-schemaxml-to-escposxmlfmtxml-viewerxhbtestrail-clisvg-sprite-datavs-parse@crystaldesign/web-planner-logic@dailykit/xml-escpos-helper@cwi/shp-cicbr-rateskangarooui-legokarma-tests-results-comparatorjnexiphoto-event-exporteriwechatjunit-failureskoa-buddy@bluejeans/react-native-windowsspring-summerstrings-toolsp-workbench-api-proxytsvgtk-dwml-to-jsontimesheettps-watchts-odata-scaffolder@andrew0687/xml-viewer@bible-reader/bible-converter@datahex/escpos-xmlxsd2ts-defxsd2tsdzotero-pluginvue2minavue-svg-component-creatorupnp-ts@freddieridell/jest-emotion@infinitebrahmanuniverse/nolb-xm@laboratoriobridge/xcdatamodel@mxw/scene-converter@nindaff/ascii-tree@noname-land/svg-sprite-data@react-native-windows/cli@scripture-app/bible-converter@phanish/xml-schema@packem/file-plugin@rgwch/samdastoolsmo-pdmmodular-behavior-treemmlp-ebay-apipappelnslurmpb-simplenlgrunegrid.html-to-objectrnw-wpf-testqb-sierrareact-icon-loaderreact-native-testwebreact-native-windows-imagineanode-dhtmlx-excelnode-express-typeorm-appnimvelo-communicatornginx-cache-purgenetscreens-player-commonnode-seederplex-cache-fillerplex-protocolpostcss-xml-transformquothproject-mnemosynesitemap-xml-readersitemap2arraygodex-printergulp-mp-npmhd-xlsxinodientlight-smslib-cli-wormlsbucketlogcatisloglrs-xml-parsermame2jsonmath-expressionsmcxclient
1.2.1

10 years ago

1.2.0

11 years ago

1.1.0

11 years ago

1.0.0

11 years ago

0.1.0

11 years ago

0.0.1

11 years ago