Created
March 9, 2021 01:06
-
-
Save sinetoami/8a643df813e5a8995c2d2c868ac73904 to your computer and use it in GitHub Desktop.
Validador XSD/XML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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