gulp-xml
a gulp plugin to process xml file with xml2js.
The creation of this modules is due to that the module gulp-xml2js is not so powerful as the original xml2js.
Usage
check the gulpfile.js
in this module you will see the following:
var gulp = require('gulp'),rename = require('gulp-rename'),xml = require('.');gulp.task('default', function () {gulp.src('./test/src.xml').pipe(xml({// options to initialize an XML2JS PARSERparseOpts: {trim: true},// options to initialize an XML2JS BUILDERbuildOpts: {renderOpts: {pretty: false},allowSurrogateChars: true,cdata: true},// outType: build an xml file or a json string, DEFAULT ture// callback after building the output contents with the result passed in// besides, if the return value of callback equals null, undefinded or an empty string and so on,// it will be igoredcallback: function (result) {return result.replace(/search/g, 'MySearch');}}))// please handle renaming the files by yourself or not.pipe(rename({basename: 'dist'})).pipe(gulp.dest('./test'));});
Yeah, as yo see it's very simple. Just enjoy it!
Test
run the following script:
npm inpm test
Thanks
Thanks to the original author @Leonidas-from-XIV and the code pattern of gulp-replace.
License
MIT License (Expat)