UNPKG

@jnxplus/xml

Version:
24 lines 836 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.readXmlTree = readXmlTree; exports.readXml = readXml; exports.xmlToString = xmlToString; const fs = require("fs"); const xmldoc_1 = require("xmldoc"); function readXmlTree(tree, path) { var _a; const fileText = (_a = tree.read(path)) === null || _a === void 0 ? void 0 : _a.toString(); if (!fileText) { throw new Error(`Unable to read ${path}`); } return new xmldoc_1.XmlDocument(fileText); } function readXml(filePath) { const fileText = fs.readFileSync(filePath, 'utf-8'); return new xmldoc_1.XmlDocument(fileText); } function xmlToString(xmlDoc) { return ('<?xml version="1.0" encoding="UTF-8"?>' + xmlDoc.toString({ compressed: true, preserveWhitespace: true })); } //# sourceMappingURL=index.js.map