{"name":"xmlbuilder2","version":"2.4.0","keywords":["xml","xmlbuilder"],"author":{"name":"Ozgur Ozcitak","email":"oozcitak@gmail.com"},"license":"MIT","_id":"xmlbuilder2@2.4.0","maintainers":[{"name":"oozcitak","email":"oozcitak@gmail.com"}],"contributors":[],"homepage":"http://github.com/oozcitak/xmlbuilder2","bugs":{"url":"http://github.com/oozcitak/xmlbuilder2/issues"},"dist":{"shasum":"fb6c5171bef1bcb984c88cfef5210e17b7b841cd","tarball":"http://registry-npm.ywwl.com/xmlbuilder2/download/xmlbuilder2-2.4.0.tgz","fileCount":80,"integrity":"sha512-KrOVUGD65xTQ7ZA+GMQGdBSpe1Ufu5ylCQSYVk6QostySDkxPmAQ0WWIu7dR3JjLfVbF22RFQX7KyrZ6VTLcQg==","signatures":[{"sig":"MEUCIQD5VhobDCxBasrN9j0w4Ijyh97tAEKMhBnRxFrXAhCbWwIgfs4E9/T+GcqI4YPRVOWRhBwPzNYCa37NZ6hrdUHsYoM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1085087,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfX0WOCRA9TVsSAnZWagAAGBcP/An11Bjda1RqsAzZjXEO\naoUgQS2QkzZ6sgJtadJ1XBeMAYzpiiJEaLqLehmcGDmMoppuJpsIu8XFu5Qf\nxEW+g4VJwYQ7Zgk/Q7O3VUhoFEpsX6IfxAhnxr+mKmt3ABhXSXopwZfTLPdT\n7YVC7cqzOodCXtvtRHrGweSB00Z2jEJUmr4uzwXucqrej7mBgqcSmWH5FNEY\nJ8b61LnoFkVNacN4WGnlag40he5Hr8Agp9Hy+yQUeEHCMaTPxINdN9S+BNDe\nj9OjLqa9zOiWM717wF3oAIK5/pbLhUc8ula19aTPIxkTGpxWGjReB1f6sHe2\n8guXDPe4pTRLUSdX2MRiASE/Fn9MU3nc1Y5AzMo5VtVY4amG5nTbfkIL2JP+\nY6huJN/e0xao1lWj0Yv/11DCOU5xlOXhw/TmLMXeZvvFZvSGycJPd4/rtyix\nDq77/XSI5hMYAKQDV6ATp+triWvWiyyFSj/j58puUl6wl1680gVnUfQyGGC9\nPbZ1WVPlTtlWSKF3Hz9E2zul9ZonzI2B9JFFLuPyOQMsd5JXfbcXFKGx8vZO\n5PHbSVIWs9byGarKylRMqHuw5aZiHuxTjQIRcPtGtGRw+H+a8CVqKW/5OGUH\nnx8pNUySghzaY4tuRdFFxp6FJxrCeSVGhZaRi7bnEhwqWY3getJIvvPNN119\nz6+g\r\n=d4/B\r\n-----END PGP SIGNATURE-----\r\n","size":221765,"noattachment":false,"key":"/xmlbuilder2/-/xmlbuilder2-2.4.0.tgz"},"jest":{"testRegex":"/test/.*\\.test\\.tsx?$","transform":{"^.+\\.tsx?$":"ts-jest"},"testEnvironment":"node","collectCoverageFrom":["src/**/*.{ts,tsx}"],"testPathIgnorePatterns":["/test/browser/.*"]},"main":"./lib/index","types":"./lib/index.d.ts","browser":"./lib/xmlbuilder2.min.js","engines":{"node":">=10.0"},"gitHead":"bf22aeef1b6fd91e717d70298db8129573890518","scripts":{"perf":"npm run pretest && ts-node ./perf/perf.ts","test":"jest --coverage","perf-cb":"npm run pretest && ts-node ./perf/perf-cb.ts","pretest":"rm -rf ./lib && tsc --version && tsc && webpack","servedocs":"(cd docs && bundle exec jekyll serve)","postpublish":"git push --all && git push --tags","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"},"_npmUser":{"name":"oozcitak","email":"oozcitak@gmail.com"},"repository":{"url":"git://github.com/oozcitak/xmlbuilder2.git","type":"git"},"_npmVersion":"6.14.4","description":"An XML builder for node.js","directories":{},"_nodeVersion":"12.16.3","dependencies":{"js-yaml":"3.14.0","@types/node":"14.6.2","@oozcitak/dom":"1.15.8","@oozcitak/util":"8.3.8","@oozcitak/infra":"1.0.8"},"_hasShrinkwrap":false,"devDependencies":{"glob":"*","jest":"*","chalk":"*","xpath":"*","dedent":"*","core-js":"3.6.5","ts-jest":"*","ts-node":"*","webpack":"*","iedriver":"*","libxmljs":"*","benchmark":"*","ts-loader":"*","typescript":"*","xmlbuilder":"*","@types/jest":"*","geckodriver":"*","webpack-cli":"*","babel-loader":"*","chromedriver":"*","@types/dedent":"*","@types/js-yaml":"3.11.1","@types/libxmljs":"*","harmony-reflect":"*","@types/benchmark":"*","@babel/preset-env":"*","es6-proxy-polyfill":"*","selenium-webdriver":"*","@types/chromedriver":"*","@babel/runtime-corejs3":"7.10.3","@types/selenium-webdriver":"*"},"_npmOperationalInternal":{"tmp":"tmp/xmlbuilder2_2.4.0_1600079246005_0.8262517528174809","host":"s3://npm-registry-packages"},"readme":"# xmlbuilder2\n\nAn XML builder for [node.js](https://nodejs.org/).\n\n![GitHub License](https://img.shields.io/github/license/oozcitak/xmlbuilder2)\n![NPM Version](https://img.shields.io/npm/v/xmlbuilder2)\n![NPM Downloads](https://img.shields.io/npm/dm/xmlbuilder2)\n![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hm/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\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/oozcitak)](https://github.com/sponsors/oozcitak)\n\n### Installation:\n\n``` sh\nnpm install xmlbuilder2\n```\n\n### Documentation:\n\nSee: https://oozcitak.github.io/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### Donations:\nPlease consider becoming a sponsor to help support development.\n\n[:heart: Github Sponsors](https://github.com/sponsors/oozcitak)\n","publish_time":1600079246156,"_cnpm_publish_time":1600079246156,"dist-tags":{"latest":"4.0.3"}}