Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Validador XSD/XML
import * as fs from "fs";
import * as libxml from "libxmljs";
try {
const xsdStr = fs.readFileSync("RecepcaoNFSe_v1.00.xsd", "utf8");
const xml = fs.readFileSync("teste.xml", "utf8");
const xsd = libxml.parseXml(xsdStr);
const xmlDoc = libxml.parseXml(xml);
console.log(xmlDoc.validate(xsd));
console.log(xmlDoc.validationErrors);
} catch (error) {
console.error(error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment