Skip to content

Repository files navigation

gulp-xml-validator

Gulp plugin to validate XML.

License Version GitHub branch check runs

Installation

$ npm install gulp-xml-validator --save-dev

Usage

// Gulpfile.mjs
import gulp from 'gulp';
import { xmlValidator } from 'gulp-xml-validator';

gulp.task('lint', () =>
  gulp.src('**/*.xml')
    .pipe(xmlValidator())
);

Note

This package encourages the use of ESM. Read how to migrate your Gulpfile.

Validation

Files are parsed with xmldom. Any message it reports fails the task, including warnings: xmldom raises warnings for malformed XML it can recover from, such as unquoted attribute values (<a b=c>) or attributes without a value (<a b>).

All files are checked before the task fails, and the error lists every problem found. Files that pass validation continue down the stream.

Options

options.mimeType

Type: string
Default: "text/xml"

Allows modifying the MIME type passed to DOMParser().parseFromString(). An unsupported MIME type fails the task.

License

This work is licensed under The MIT License.

Releases

Sponsor this project

Packages

Used by

Contributors

Languages