Status: Work In Progress
Parser for CommerceML 2.10 standard developed by 1c.ru.
Standard description: https://v8.1c.ru/tekhnologii/obmen-dannymi-i-integratsiya/standarty-i-formaty/standarty-commerceml/commerceml-2/
- Types description in English
- SAX XML parser suitable for large files
- NodeJS
- TypeScript
- xojs/xo with plugins for TypeScript - linting
- ESLint - linting in the WebStorm with ESLint plugin
- ts-jest - Testing & Coverage
npm install --save commerceml-parser
or
yarn add commerceml-parser
Note: Interfaces for browsers were extracted into commerceml-parser-core
package.
Install it with npm install commerceml-parser-core --save-dev
or yarn add commerceml-parser-core --dev
Have a look at usage examples in tests /spec/example.spec.ts
.
Run example: npm run example
or yarn example
Here is a common usage example:
import {CommerceMlImportParser} from 'commerceml-parser/import-parser';
import {createReadStream} from "fs";
// Create parser for CommerceML catalog import file
const catalogImportParser = new CommerceMlImportParser();
// Define handler for commercial information header
catalogImportParser.onCommercialInformation(commercialInformation => {
console.log('commercialInformation', JSON.stringify(commercialInformation));
});
// Define handler for classifier XML block
catalogImportParser.onClassifier(classifier => {
console.log('classifier', JSON.stringify(classifier));
});
// Define handler for classifier group XML blocks
catalogImportParser.onClassifierGroup(classifierGroup => {
console.log('classifierGroup', JSON.stringify(classifierGroup));
});
// Read CommerceML file and feed it to the parser stream
await catalogImportParser.parse(createReadStream('./data/import0_1_with_nested_groups.xml'));
v2.10
v2.08
@kirill-zhirnov for his commerceml-js parser written in CoffeeScript.
MIT (c) 2020 Viacheslav Dobromyslov <viacheslav@dobromyslov.ru>