{"_id":"@campionfellin/xmlbuilder2","_rev":"2-1b0436d5977159f3779e44b811dd9e80","name":"@campionfellin/xmlbuilder2","dist-tags":{"latest":"2.4.2"},"versions":{"2.4.1":{"name":"@campionfellin/xmlbuilder2","version":"2.4.1","keywords":["xml","xmlbuilder"],"homepage":"http://github.com/oozcitak/xmlbuilder2","description":"An XML builder for node.js","author":{"name":"Campion Fellin","email":"campionfellin@gmail.com"},"contributors":[],"license":"MIT","repository":{"type":"git","url":"git://github.com/campionfellin/xmlbuilder2.git"},"bugs":{"url":"http://github.com/campionfellin/xmlbuilder2/issues"},"main":"./lib/index","browser":"./lib/xmlbuilder2.min.js","engines":{"node":">=10.0"},"types":"./lib/index.d.ts","dependencies":{"@oozcitak/dom":"1.15.8","@oozcitak/infra":"1.0.8","@oozcitak/util":"8.3.8","@types/node":"*","js-yaml":"3.14.0"},"devDependencies":{"@babel/preset-env":"*","@babel/runtime-corejs3":"7.10.3","@types/benchmark":"*","@types/chromedriver":"*","@types/dedent":"*","@types/jest":"*","@types/js-yaml":"3.11.1","@types/libxmljs":"*","@types/selenium-webdriver":"*","babel-loader":"*","benchmark":"*","chalk":"*","chromedriver":"*","core-js":"3.6.5","dedent":"*","es6-proxy-polyfill":"*","geckodriver":"*","glob":"*","harmony-reflect":"*","iedriver":"*","jest":"*","libxmljs":"*","selenium-webdriver":"*","ts-jest":"*","ts-loader":"*","ts-node":"*","typescript":"*","webpack":"*","webpack-cli":"*","xmlbuilder":"*","xpath":"*"},"jest":{"transform":{"^.+\\.tsx?$":"ts-jest"},"testRegex":"/test/.*\\.test\\.tsx?$","testPathIgnorePatterns":["/test/browser/.*"],"testEnvironment":"node","collectCoverageFrom":["src/**/*.{ts,tsx}"]},"scripts":{"pretest":"rm -rf ./lib && tsc --version && tsc && webpack","test":"jest --coverage","perf":"npm run pretest && ts-node ./perf/perf.ts","perf-cb":"npm run pretest && ts-node ./perf/perf-cb.ts","prof-serialize":"npm run pretest && rm -f isolate-*-v8.log && node --prof ./perf/prof-serialize.js && find . -name isolate-*-v8.log -exec mv {} isolate-v8.log ; && node --prof-process isolate-v8.log > isolate-serialize.log && rm isolate-v8.log","postpublish":"git push --all && git push --tags","servedocs":"(cd docs && bundle exec jekyll serve)"},"gitHead":"c1c467a4458bc754a262a89c0e4fb893c1035590","_id":"@campionfellin/xmlbuilder2@2.4.1","_nodeVersion":"10.5.0","_npmVersion":"7.0.10","dist":{"integrity":"sha512-/TYAh2VOhJXYx34NDKRk5fFw1G4cvtxkNXJRe3xyXbpbIKHovBB6B0vtoxeGXuSgjvStig4Cmr/nXbXh5F8enw==","shasum":"0cbc96fcae75d95b0299581de81d06a56c4e6cbf","tarball":"https://registry.npmjs.org/@campionfellin/xmlbuilder2/-/xmlbuilder2-2.4.1.tgz","fileCount":4,"unpackedSize":17167,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgU3NuCRA9TVsSAnZWagAADRgP/ihb85sH7Y1meoGAO/je\nl293BbwVkt8BIPfHCCBP5Rx3CtXtqBe1LIajkQKit42zVR+gfKQVEqTjOf2j\nA81rjz9QprTZVC1kGrkjKSITj9ARE2cI3XwU6zkVNJG6R243XrCJ7M4BVWAu\noRoWhdzeon+485d9Nfxq81cUq0zZa4nl8C2+seJBzZksvcz6pDlFJdJDtAmI\n50d2GiAM4O+DIpsxbdnV2APs2ktd/Mx44fq1d4IIaNDMS4fDFno+35hpOsXC\nBEu17ZfBCX92DFfksUCAcm4PF07BuoDQ0bQtdLU6oFZPvOHirEs9qOo3FydM\nrvy+cxMcnHsMR/EiuUA5j/EOvySI7iC6RF6xG4TuTXGekxq6RZT2Sl6LoR6E\nDJIq+67YWB2HmysMqV2KXxwNtWqgUTW4UjblE+nlwIiezOqyGh8avqQB+Qfv\nUI6A9U3lfYgkXMVKiDfNBsEp+HKZwA52pncEDsPKckDaAanNZjUYQem5+C+7\nGB5LzZezdmAOS56BfD3xwAwyehHlGSCul0jfL+8O5M/Vautmu8IvYK8Tk3Mq\nCdC1alk5Mb8dkBsbVBH5AQrcQk/FlElWWl3gsDF1NTh6+hji76I2mEDEEi1W\nbQrpf8bmojVmwvLp193mPGtU2tR/DQvGCgzqQmG28aOncnH4YKL7Xqnk0b9w\nb+/q\r\n=vtYp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDc9ixwKdNSbZFsuUpA5Yhzz7CPb+7c1SmWJ8BRMMzJiwIgTtI4GArteDMgskJ9fXy+I1gcIhjjvRcKU191tmnAq4w="}]},"_npmUser":{"name":"campionfellin","email":"campionfellin@gmail.com"},"directories":{},"maintainers":[{"name":"campionfellin","email":"campionfellin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xmlbuilder2_2.4.1_1616081773989_0.1757740715932965"},"_hasShrinkwrap":false},"2.4.2":{"name":"@campionfellin/xmlbuilder2","version":"2.4.2","keywords":["xml","xmlbuilder"],"homepage":"http://github.com/campionfellin/xmlbuilder2","description":"An XML builder for node.js","author":{"name":"Campion Fellin","email":"campionfellin@gmail.com"},"contributors":[],"license":"MIT","repository":{"type":"git","url":"git://github.com/campionfellin/xmlbuilder2.git"},"bugs":{"url":"http://github.com/campionfellin/xmlbuilder2/issues"},"main":"./lib/index","browser":"./lib/xmlbuilder2.min.js","engines":{"node":">=10.0"},"types":"./lib/index.d.ts","dependencies":{"@oozcitak/dom":"1.15.8","@oozcitak/infra":"1.0.8","@oozcitak/util":"8.3.8","@types/node":"*","js-yaml":"3.14.0"},"devDependencies":{"@babel/preset-env":"*","@babel/runtime-corejs3":"7.10.3","@types/benchmark":"*","@types/chromedriver":"*","@types/dedent":"*","@types/jest":"*","@types/js-yaml":"3.11.1","@types/libxmljs":"*","@types/selenium-webdriver":"*","babel-loader":"*","benchmark":"*","chalk":"*","chromedriver":"*","core-js":"3.6.5","dedent":"*","es6-proxy-polyfill":"*","geckodriver":"*","glob":"*","harmony-reflect":"*","iedriver":"*","jest":"*","libxmljs":"*","selenium-webdriver":"*","ts-jest":"*","ts-loader":"*","ts-node":"*","typescript":"*","webpack":"*","webpack-cli":"*","xmlbuilder":"*","xpath":"*"},"jest":{"transform":{"^.+\\.tsx?$":"ts-jest"},"testRegex":"/test/.*\\.test\\.tsx?$","testPathIgnorePatterns":["/test/browser/.*"],"testEnvironment":"node","collectCoverageFrom":["src/**/*.{ts,tsx}"]},"scripts":{"pretest":"rm -rf ./lib && tsc --version && tsc && webpack","test":"jest --coverage","perf":"npm run pretest && ts-node ./perf/perf.ts","perf-cb":"npm run pretest && ts-node ./perf/perf-cb.ts","prof-serialize":"npm run pretest && rm -f isolate-*-v8.log && node --prof ./perf/prof-serialize.js && find . -name isolate-*-v8.log -exec mv {} isolate-v8.log ; && node --prof-process isolate-v8.log > isolate-serialize.log && rm isolate-v8.log","postpublish":"git push --all && git push --tags","servedocs":"(cd docs && bundle exec jekyll serve)"},"licenseText":"MIT License\n\nCopyright (c) 2019 Ozgur Ozcitak\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@campionfellin/xmlbuilder2@2.4.2","dist":{"shasum":"efa1e3763da83dc9f1b2ea25758921ec4b85be63","integrity":"sha512-oKKxHbRC1ps2j0VCzQjrsW3BCI49q524YdWdA2x3WCQr2iheOgP/5VwhYBoHnY8SK7LTpJXLguyNR453dyE/Aw==","tarball":"https://registry.npmjs.org/@campionfellin/xmlbuilder2/-/xmlbuilder2-2.4.2.tgz","fileCount":85,"unpackedSize":1086149,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgU/1TCRA9TVsSAnZWagAA/LAQAIxch2QfEaresjYdrpM9\nZGsjXu7Nb9NiXWVsv4a0akUfE1SvU5VJpV4ulFlt6zkubG6IJ5mEivjINZkv\nlW++KelLLsB4g2k1s5rtG5r4tpAxWAcqsuWBv6pCBUBlJ6sF9How9HjSF8jv\nwz2aAJ1hdYYcPGurbYSu49nHiuSXVGsOJYZOt5NbXft19iHmTOPGwP9HjPKR\nAa5aqxElVnTxn//UMzyXFZBw9GqcAghoqQt0kY6j2gjqEN+zquUDqKrn3RWz\nwbGcCFAiedWVq6jQxD2Y4uR+gqMy/mmLtDN0z9NL5yTenY5wB0SEmrdh57vk\nq6oKkQae9Xb7if1+WncT8BP4KZCqn2t9EH+Lsh2+ofsBf4GqhpQetyOtRJUr\n6PeMCrHFuy9XA+KITMZsxB5WedJRaKILmhxLUFZm2v1Y33WBZxdbWM3Q+IaH\n8c2tdwkBwHVB9EFdA/Q4iK46nZ+yItSy3vGEj4ePYaprCi2fV6bH2Oymfe+y\nLtOmOh+5ONt8XEo54p/BYL8EtSeTef35CykL2jZsFtX0FP2NtjelBy95bZic\nTrYzNeiT6/bSn1F6PjUjfdPxpyzgKlIKczjNsvxSjJ04cDhhOxEpRDcK7xHh\ntygvJXTg6Q9dHB/NHWeO/A+CJnxCNZaibSrchXfEWMmUspiv+dK2K1qxrwqg\nGXaE\r\n=UpJB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD6QEh6B3MKsXVIO5BYpfE2ReGJv0SoKyJ7ZfevQ8xgIAIgC9ZZ4yx54eaA0zglXhmeTvUVK7wZsSbe/uGiylHI+ZY="}]},"_npmUser":{"name":"campionfellin","email":"campionfellin@gmail.com"},"directories":{},"maintainers":[{"name":"campionfellin","email":"campionfellin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xmlbuilder2_2.4.2_1616117074486_0.7299947721605389"},"_hasShrinkwrap":false}},"time":{"created":"2021-03-18T15:36:13.915Z","2.4.1":"2021-03-18T15:36:14.134Z","modified":"2022-04-04T21:34:57.602Z","2.4.2":"2021-03-19T01:24:34.700Z"},"maintainers":[{"name":"campionfellin","email":"campionfellin@gmail.com"}],"description":"An XML builder for node.js","homepage":"http://github.com/campionfellin/xmlbuilder2","keywords":["xml","xmlbuilder"],"repository":{"type":"git","url":"git://github.com/campionfellin/xmlbuilder2.git"},"contributors":[],"author":{"name":"Campion Fellin","email":"campionfellin@gmail.com"},"bugs":{"url":"http://github.com/campionfellin/xmlbuilder2/issues"},"license":"MIT","readme":"# xmlbuilder2\n\nAn XML builder for [node.js](https://nodejs.org/).\n\n[![License](https://badgen.net/github/license/oozcitak/xmlbuilder2)](http://opensource.org/licenses/MIT)\n[![NPM Version](https://badgen.net/npm/v/xmlbuilder2)](https://www.npmjs.com/package/xmlbuilder2)\n[![NPM Downloads](https://badgen.net/npm/dm/xmlbuilder2)](https://www.npmjs.com/package/xmlbuilder2)\n[![jsDelivr](https://badgen.net/jsdelivr/hits/npm/xmlbuilder2)](https://www.jsdelivr.com/package/npm/xmlbuilder2)\n\n[![Node.js CI](https://github.com/oozcitak/xmlbuilder2/workflows/build/badge.svg)](https://github.com/oozcitak/xmlbuilder2/actions)\n[![Code Coverage](https://codecov.io/gh/oozcitak/xmlbuilder2/branch/master/graph/badge.svg)](https://codecov.io/gh/oozcitak/xmlbuilder2)\n[![Dev Dependency Status](https://badgen.net/david/dep/oozcitak/xmlbuilder2)](https://david-dm.org/oozcitak/xmlbuilder2)\n\n### Installation:\n\n``` sh\nnpm install xmlbuilder2\n```\n\n### Usage:\n\n`xmlbuilder2` is a wrapper around DOM nodes which adds chainable functions to make it easier to create and work with XML documents. For example the following XML document:\n\n``` xml\n<?xml version=\"1.0\"?>\n<root att=\"val\">\n  <foo>\n    <bar>foobar</bar>\n  </foo>\n  <baz/>\n</root>\n```\n\ncan be created with the following function chain:\n\n``` js\nconst { create } = require('xmlbuilder2');\n\nconst root = create({ version: '1.0' })\n  .ele('root', { att: 'val' })\n    .ele('foo')\n      .ele('bar').txt('foobar').up()\n    .up()\n    .ele('baz').up()\n  .up();\n\n// convert the XML tree to string\nconst xml = root.end({ prettyPrint: true });\nconsole.log(xml);\n```\n\n___\n\nThe same XML document can be created by converting a JS object into XML nodes:\n\n``` js\nconst { create } = require('xmlbuilder2');\n\nconst obj = {\n  root: {\n    '@att': 'val',\n    foo: {\n      bar: 'foobar'\n    },\n    baz: {}\n  }\n};\n\nconst doc = create(obj);\nconst xml = doc.end({ prettyPrint: true });\nconsole.log(xml);\n```\n___\n\n`xmlbuilder2` can also parse and serialize XML documents from different formats:\n```js\nconst { create } = require('xmlbuilder2');\n\nconst xmlStr = '<root att=\"val\"><foo><bar>foobar</bar></foo></root>';\nconst doc = create(xmlStr);\n\n// append a 'baz' element to the root node of the document\ndoc.root().ele('baz');\n\nconst xml = doc.end({ prettyPrint: true });\nconsole.log(xml);\n```\nwhich would output the same document string at the top of this page.\n\nOr you could return a JS object by changing the `format` argument to `'object'`:\n```js\nconst obj = doc.end({ format: 'object' });\nconsole.log(obj);\n```\n```js\n{\n  root: {\n    '@att': 'val',\n    foo: {\n      bar: 'foobar'\n    },\n    baz: {}\n  }\n}\n```\n\n___\n\nYou can convert between formats in one go with the `convert` function:\n\n```js\nconst { convert } = require('xmlbuilder2');\n\nconst xmlStr = '<root att=\"val\"><foo><bar>foobar</bar></foo></root>';\nconst obj = convert(xmlStr, { format: \"object\" });\n\nconsole.log(obj);\n```\n```js\n{\n  root: {\n    '@att': 'val',\n    foo: {\n      bar: 'foobar'\n    }\n  }\n}\n```\n\n___\n\nIf you need to do some processing:\n\n``` js\nconst { create } = require('xmlbuilder2');\n\nconst root = create().ele('squares');\nroot.com('f(x) = x^2');\nfor(let i = 1; i <= 5; i++)\n{\n  const item = root.ele('data');\n  item.att('x', i);\n  item.att('y', i * i);\n}\n\nconst xml = root.end({ prettyPrint: true });\nconsole.log(xml);\n```\n\nThis will result in:\n\n``` xml\n<?xml version=\"1.0\"?>\n<squares>\n  <!-- f(x) = x^2 -->\n  <data x=\"1\" y=\"1\"/>\n  <data x=\"2\" y=\"4\"/>\n  <data x=\"3\" y=\"9\"/>\n  <data x=\"4\" y=\"16\"/>\n  <data x=\"5\" y=\"25\"/>\n</squares>\n```\n\n### Usage in the browser:\n\nYou can build the minified production bundle (`lib/xmlbuilder2.min.js`) after cloning the repository and issuing `npx webpack` in your terminal. The bundle is also in the npm package, so you can also use a public npm CDN like [jsDelivr](https://www.jsdelivr.com/) or [unpkg](https://unpkg.com/):\n\n```html\n<!-- latest version from jsDelivr -->\n<script src=\"https://cdn.jsdelivr.net/npm/xmlbuilder2/lib/xmlbuilder2.min.js\"></script>\n<!-- latest version from unpkg -->\n<script src=\"https://unpkg.com/xmlbuilder2/lib/xmlbuilder2.min.js\"></script>\n```\n\n### Documentation:\n\nSee: https://oozcitak.github.io/xmlbuilder2/\n\n### Donations:\nPlease consider becoming a backer or sponsor to help support development.\n\n[<img src=\"https://opencollective.com/webpack/donate/button@2x.png?color=blue\" alt=\"Donate Button\" width=\"300\"/>](https://opencollective.com/xmlbuilder2)\n","readmeFilename":"README.md"}