docs/v4/4.XMLValidator.md
XMLParser uses XMLValidator on demand.
```js
const {XMLParser} = require("fast-xml-parser");
const parser = new XMLParser(options);
try{
let result = parser.parse(XMLdata, true);
}catch(err){
//:
}
```
XML Parser throws error when XML Validator returns error. XML Validator can also be used directly without XML Parser;
```js
const {XMLValidator} = require("fast-xml-parser");
const result = XMLValidator.validate(xmlData, {
allowBooleanAttributes: true
});
```
* XMLValidator returns true if no issue is found.
* XMLValidator returns an error object if any issue is found.
```js
{
err: {
code: string;
msg: string,
line: number,
col: number
};
};
```
## Options
### allowBooleanAttributes
Set it to `true` when a tag can have boolean attributes.
### unpairedTags
Unpaired Tags are the tags which don't have matching closing tag. Eg `<br>` in HTML. You can parse unpaired tags by providing their list to the parser, validator and builder.
```js
const xmlData = `<parent><extra></parent>`;
const result = XMLValidator.validate( xmlData, {
unpairedTags: ["extra"]
});
```
[> Next: Entities](./5.Entities.md)