{"id":25306780,"url":"https://github.com/davidcalhoun/jstoxml","last_synced_at":"2025-05-15T07:05:22.043Z","repository":{"id":510374,"uuid":"2127451","full_name":"davidcalhoun/jstoxml","owner":"davidcalhoun","description":"JavaScript object to XML converter (useful for RSS, podcasts, GPX, AMP, etc)","archived":false,"fork":false,"pushed_at":"2025-04-12T03:01:44.000Z","size":1105,"stargazers_count":182,"open_issues_count":1,"forks_count":22,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-12T21:33:48.386Z","etag":null,"topics":["amp","amp-html","gpx","html","jsx","jsx-syntax","podcast","rss","xml"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidcalhoun.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://www.paypal.me/davidbcalhoun"}},"created_at":"2011-07-30T03:50:44.000Z","updated_at":"2025-04-12T01:56:39.000Z","dependencies_parsed_at":"2023-07-05T15:01:43.879Z","dependency_job_id":"d69b6d80-ea99-4185-baa2-59add2ab4b75","html_url":"https://github.com/davidcalhoun/jstoxml","commit_stats":{"total_commits":218,"total_committers":8,"mean_commits":27.25,"dds":"0.050458715596330306","last_synced_commit":"a0d759d25bc63e61138238ca438d6bef07a47e58"},"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcalhoun%2Fjstoxml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcalhoun%2Fjstoxml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcalhoun%2Fjstoxml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcalhoun%2Fjstoxml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidcalhoun","download_url":"https://codeload.github.com/davidcalhoun/jstoxml/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254292040,"owners_count":22046426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amp","amp-html","gpx","html","jsx","jsx-syntax","podcast","rss","xml"],"created_at":"2025-02-13T10:52:44.897Z","updated_at":"2025-05-15T07:05:17.031Z","avatar_url":"https://github.com/davidcalhoun.png","language":"JavaScript","funding_links":["https://www.paypal.me/davidbcalhoun"],"categories":[],"sub_categories":[],"readme":"# jstoxml\n\n[![npm downloads](https://img.shields.io/npm/dm/jstoxml.svg)](https://www.npmjs.com/package/jstoxml)\n\n### Convert JavaScript objects (and JSON) to XML (for RSS, Podcasts, etc.)\n\nEveryone loves JSON, and more and more folks want to move that direction, but we still need things outputted in XML! Particularly for [RSS feeds](http://www.rssboard.org/rss-specification) and [Podcasts](http://www.apple.com/itunes/podcasts/specs.html).\n\nThis is inspired by [node-jsontoxml](https://github.com/soldair/node-jsontoxml), which was found to be a bit too rough around the edges. jstoxml attempts to fix that by being more flexible.\n\n### Requirements\n\nNode 16+ or a code bundler that understands ES Modules.\n\n### Installation\n\n- npm install jstoxml\n\n### Simple example\n\n```js\nimport { toXML } from 'jstoxml';\n\n// toXML(content, config)\nconst content = {\n    a: {\n        foo: 'bar'\n    }\n};\nconst config = {\n    indent: '    '\n};\n\ntoXML(content, config);\n/*\nOutput:\n`\u003ca\u003e\n    \u003cfoo\u003ebar\u003c/foo\u003e\n\u003c/a\u003e`\n*/\n```\n\n### Configuration object options (passed as second parameter to `toXML()`)\n\n| Key name              | Type                | Default                                                      | Description                                                                                                                                                                             |\n| --------------------- | ------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| indent                | `string`            |                                                              | Indent string, repeated n times (where n=tree depth).                                                                                                                                   |\n| header                | `string`, `boolean` |                                                              | Outputs a simple XML 1.0 UTF-8 header when true. Can also be set to a custom string.                                                                                                    |\n| attributeReplacements | `object`            | `{ \"\u003c\": \"\u0026lt;\", \"\u003e\": \"\u0026gt;\", \"\u0026\": \"\u0026amp;\", \"\\\"\": \"\u0026quot;\" }` | XML attribute value substrings to replace (e.g. `\u003ca attributeKey=\"attributeValue\" /\u003e`). Does not double encode HTML entities (e.g. `\u0026lt;` is preserved and NOT converted to `\u0026amp;lt`). |\n| attributeFilter       | `function`          |                                                              | Filters out attributes based on user-supplied function.                                                                                                                                 |\n| attributeExplicitTrue | `boolean`           | `false`                                                      | When true explicitly outputs `true` attribute value strings, e.g. `\u003ca foo='true' /\u003e` instead of `\u003ca foo /\u003e`.                                                                            |\n| contentMap            | `function`          |                                                              | Custom map function to transform XML content. Runs after `contentReplacements`.                                                                                                         |\n| contentReplacements   | `object`            | `{ \"\u003c\": \"\u0026lt;\", \"\u003e\": \"\u0026gt;\", \"\u0026\": \"\u0026amp;\", \"\\\"\": \"\u0026quot;\" }` | XML content strings to replace (e.g. `\u003ca\u003eThis \u0026 that\u003c/a\u003e` becomes `\u003ca\u003eThis \u0026amp; that\u003c/a\u003e`).                                                                                            |\n| selfCloseTags         | `boolean`           | `true`                                                       | Whether tags should be self-closing.                                                                                                                                                    |\n\n### Changelog\n\n#### Version 7.0.0\n\n- **BREAKING**: only support ES Modules, drops support for UMD (CommonJS, window global) and drop the minified code from the package.\n\nFor more changelog history, see `CHANGELOG.md`.\n\n#### Past changes\n\n- See CHANGELOG.md for a full history of changes.\n\n### Other Examples\n\nFirst you'll want to import jstoxml in your script, and assign the result to the namespace variable you want to use (in this case jstoxml):\n\n```javascript\nimport { toXML } from 'jstoxml';\n```\n\n#### Example 1: Simple object\n\n```javascript\ntoXML({\n    foo: 'bar',\n    foo2: 'bar2'\n});\n```\n\nOutput:\n\n```\n\u003cfoo\u003ebar\u003c/foo\u003e\u003cfoo2\u003ebar2\u003c/foo2\u003e\n```\n\nNote: because JavaScript doesn't allow duplicate key names, only the last defined key will be outputted. If you need duplicate keys, please use an array instead (see Example 2 below).\n\n#### Example 2: Simple array (needed for duplicate keys)\n\n```javascript\ntoXML([\n    {\n        foo: 'bar'\n    },\n    {\n        foo: 'bar2'\n    }\n]);\n```\n\nOutput:\n\n```\n\u003cfoo\u003ebar\u003c/foo\u003e\u003cfoo\u003ebar2\u003c/foo\u003e\n```\n\n#### Example 3: Simple functions\n\n```javascript\ntoXML({ currentTime: () =\u003e new Date() });\n```\n\nOutput:\n\n```\n\u003ccurrentTime\u003eMon Oct 02 2017 09:34:54 GMT-0700 (PDT)\u003c/currentTime\u003e\n```\n\n#### Example 4: XML tag attributes\n\n```javascript\ntoXML({\n    _name: 'foo',\n    _content: 'bar',\n    _attrs: {\n        a: 'b',\n        c: 'd'\n    }\n});\n```\n\nOutput:\n\n```\n\u003cfoo a=\"b\" c=\"d\"\u003ebar\u003c/foo\u003e\n```\n\n#### Example 5: Tags mixed with text content\n\nTo output text content, set a key to null:\n\n```javascript\ntoXML({\n    text1: null,\n    foo: 'bar',\n    text2: null\n});\n```\n\nOutput:\n\n```\ntext1\u003cfoo\u003ebar\u003c/foo\u003etext2\n```\n\n#### Example 6: Nested tags (with indenting)\n\n```javascript\nconst xmlOptions = {\n    header: false,\n    indent: '  '\n};\n\ntoXML(\n    {\n        a: {\n            foo: 'bar',\n            foo2: 'bar2'\n        }\n    },\n    xmlOptions\n);\n```\n\nOutput:\n\n```\n\u003ca\u003e\n  \u003cfoo\u003ebar\u003c/foo\u003e\n  \u003cfoo2\u003ebar2\u003c/foo2\u003e\n\u003c/a\u003e\n```\n\n#### Example 7: Nested tags with attributes (with indenting)\n\n```javascript\nconst xmlOptions = {\n    header: false,\n    indent: '  '\n};\n\ntoXML(\n    {\n        ooo: {\n            _name: 'foo',\n            _attrs: {\n                a: 'b'\n            },\n            _content: {\n                _name: 'bar',\n                _attrs: {\n                    c: 'd'\n                }\n            }\n        }\n    },\n    xmlOptions\n);\n```\n\nOutput:\n\n```\n\u003cooo\u003e\n  \u003cfoo a=\"b\"\u003e\n    \u003cbar c=\"d\"/\u003e\n  \u003c/foo\u003e\n\u003c/ooo\u003e\n```\n\nNote that cases like this might be especially hard to read because of the deep nesting, so it's recommend you use something like this pattern instead, which breaks it up into more readable pieces:\n\n```javascript\nconst bar = {\n    _name: 'bar',\n    _attrs: {\n        c: 'd'\n    }\n};\n\nconst foo = {\n    _name: 'foo',\n    _attrs: {\n        a: 'b'\n    },\n    _content: bar\n};\n\nconst xmlOptions = {\n    header: false,\n    indent: '  '\n};\n\nreturn toXML(\n    {\n        ooo: foo\n    },\n    xmlOptions\n);\n```\n\n#### Example 8: Complex functions\n\nFunction outputs will be processed (fed back into toXML), meaning that you can output objects that will in turn be converted to XML.\n\n```javascript\ntoXML({\n    someNestedXML: () =\u003e {\n        return {\n            foo: 'bar'\n        };\n    }\n});\n```\n\nOutput:\n\n```\n\u003csomeNestedXML\u003e\u003cfoo\u003ebar\u003c/foo\u003e\u003c/someNestedXML\u003e\n```\n\n#### Example 9: RSS Feed\n\n```javascript\nconst xmlOptions = {\n    header: true,\n    indent: '  '\n};\n\ntoXML(\n    {\n        _name: 'rss',\n        _attrs: {\n            version: '2.0'\n        },\n        _content: {\n            channel: [\n                {\n                    title: 'RSS Example'\n                },\n                {\n                    description: 'Description'\n                },\n                {\n                    link: 'google.com'\n                },\n                {\n                    lastBuildDate: () =\u003e new Date()\n                },\n                {\n                    pubDate: () =\u003e new Date()\n                },\n                {\n                    language: 'en'\n                },\n                {\n                    item: {\n                        title: 'Item title',\n                        link: 'Item link',\n                        description: 'Item Description',\n                        pubDate: () =\u003e new Date()\n                    }\n                },\n                {\n                    item: {\n                        title: 'Item2 title',\n                        link: 'Item2 link',\n                        description: 'Item2 Description',\n                        pubDate: () =\u003e new Date()\n                    }\n                }\n            ]\n        }\n    },\n    xmlOptions\n);\n```\n\nOutput:\n\n```\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003crss version=\"2.0\"\u003e\n  \u003cchannel\u003e\n    \u003ctitle\u003eRSS Example\u003c/title\u003e\n    \u003cdescription\u003eDescription\u003c/description\u003e\n    \u003clink\u003egoogle.com\u003c/link\u003e\n    \u003clastBuildDate\u003eSat Jul 30 2011 18:14:25 GMT+0900 (JST)\u003c/lastBuildDate\u003e\n    \u003cpubDate\u003eSat Jul 30 2011 18:14:25 GMT+0900 (JST)\u003c/pubDate\u003e\n    \u003clanguage\u003een\u003c/language\u003e\n    \u003citem\u003e\n      \u003ctitle\u003eItem title\u003c/title\u003e\n      \u003clink\u003eItem link\u003c/link\u003e\n      \u003cdescription\u003eItem Description\u003c/description\u003e\n      \u003cpubDate\u003eSat Jul 30 2011 18:33:47 GMT+0900 (JST)\u003c/pubDate\u003e\n    \u003c/item\u003e\n    \u003citem\u003e\n      \u003ctitle\u003eItem2 title\u003c/title\u003e\n      \u003clink\u003eItem2 link\u003c/link\u003e\n      \u003cdescription\u003eItem2 Description\u003c/description\u003e\n      \u003cpubDate\u003eSat Jul 30 2011 18:33:47 GMT+0900 (JST)\u003c/pubDate\u003e\n    \u003c/item\u003e\n  \u003c/channel\u003e\n\u003c/rss\u003e\n```\n\n#### Example 10: Podcast RSS Feed\n\n(see the [Apple docs](http://www.apple.com/itunes/podcasts/specs.html) for more information)\n\n```javascript\nconst xmlOptions = {\n    header: true,\n    indent: '  '\n};\n\ntoXML(\n    {\n        _name: 'rss',\n        _attrs: {\n            'xmlns:itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd',\n            version: '2.0'\n        },\n        _content: {\n            channel: [\n                {\n                    title: 'Title'\n                },\n                {\n                    link: 'google.com'\n                },\n                {\n                    language: 'en-us'\n                },\n                {\n                    copyright: 'Copyright 2011'\n                },\n                {\n                    'itunes:subtitle': 'Subtitle'\n                },\n                {\n                    'itunes:author': 'Author'\n                },\n                {\n                    'itunes:summary': 'Summary'\n                },\n                {\n                    description: 'Description'\n                },\n                {\n                    'itunes:owner': {\n                        'itunes:name': 'Name',\n                        'itunes:email': 'Email'\n                    }\n                },\n                {\n                    _name: 'itunes:image',\n                    _attrs: {\n                        href: 'image.jpg'\n                    }\n                },\n                {\n                    _name: 'itunes:category',\n                    _attrs: {\n                        text: 'Technology'\n                    },\n                    _content: {\n                        _name: 'itunes:category',\n                        _attrs: {\n                            text: 'Gadgets'\n                        }\n                    }\n                },\n                {\n                    _name: 'itunes:category',\n                    _attrs: {\n                        text: 'TV \u0026amp; Film'\n                    }\n                },\n                {\n                    item: [\n                        {\n                            title: 'Podcast Title'\n                        },\n                        {\n                            'itunes:author': 'Author'\n                        },\n                        {\n                            'itunes:subtitle': 'Subtitle'\n                        },\n                        {\n                            'itunes:summary': 'Summary'\n                        },\n                        {\n                            'itunes:image': 'image.jpg'\n                        },\n                        {\n                            _name: 'enclosure',\n                            _attrs: {\n                                url: 'http://example.com/podcast.m4a',\n                                length: '8727310',\n                                type: 'audio/x-m4a'\n                            }\n                        },\n                        {\n                            guid: 'http://example.com/archive/aae20050615.m4a'\n                        },\n                        {\n                            pubDate: 'Wed, 15 Jun 2011 19:00:00 GMT'\n                        },\n                        {\n                            'itunes:duration': '7:04'\n                        },\n                        {\n                            'itunes:keywords': 'salt, pepper, shaker, exciting'\n                        }\n                    ]\n                },\n                {\n                    item: [\n                        {\n                            title: 'Podcast2 Title'\n                        },\n                        {\n                            'itunes:author': 'Author2'\n                        },\n                        {\n                            'itunes:subtitle': 'Subtitle2'\n                        },\n                        {\n                            'itunes:summary': 'Summary2'\n                        },\n                        {\n                            'itunes:image': 'image2.jpg'\n                        },\n                        {\n                            _name: 'enclosure',\n                            _attrs: {\n                                url: 'http://example.com/podcast2.m4a',\n                                length: '655555',\n                                type: 'audio/x-m4a'\n                            }\n                        },\n                        {\n                            guid: 'http://example.com/archive/aae2.m4a'\n                        },\n                        {\n                            pubDate: 'Wed, 15 Jul 2011 19:00:00 GMT'\n                        },\n                        {\n                            'itunes:duration': '11:20'\n                        },\n                        {\n                            'itunes:keywords': 'foo, bar'\n                        }\n                    ]\n                }\n            ]\n        }\n    },\n    xmlOptions\n);\n```\n\nOutput:\n\n```\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003crss xmlns:itunes=\"http://www.itunes.com/dtds/podcast-1.0.dtd\" version=\"2.0\"\u003e\n  \u003cchannel\u003e\n    \u003ctitle\u003eTitle\u003c/title\u003e\n    \u003clink\u003egoogle.com\u003c/link\u003e\n    \u003clanguage\u003een-us\u003c/language\u003e\n    \u003ccopyright\u003eCopyright 2011\u003c/copyright\u003e\n    \u003citunes:subtitle\u003eSubtitle\u003c/itunes:subtitle\u003e\n    \u003citunes:author\u003eAuthor\u003c/itunes:author\u003e\n    \u003citunes:summary\u003eSummary\u003c/itunes:summary\u003e\n    \u003cdescription\u003eDescription\u003c/description\u003e\n    \u003citunes:owner\u003e\n      \u003citunes:name\u003eName\u003c/itunes:name\u003e\n      \u003citunes:email\u003eEmail\u003c/itunes:email\u003e\n    \u003c/itunes:owner\u003e\n    \u003citunes:image href=\"image.jpg\"/\u003e\n    \u003citunes:category text=\"Technology\"\u003e\n      \u003citunes:category text=\"Gadgets\"/\u003e\n    \u003c/itunes:category\u003e\n    \u003citunes:category text=\"TV \u0026amp; Film\"/\u003e\n    \u003citem\u003e\n      \u003ctitle\u003ePodcast Title\u003c/title\u003e\n      \u003citunes:author\u003eAuthor\u003c/itunes:author\u003e\n      \u003citunes:subtitle\u003eSubtitle\u003c/itunes:subtitle\u003e\n      \u003citunes:summary\u003eSummary\u003c/itunes:summary\u003e\n      \u003citunes:image\u003eimage.jpg\u003c/itunes:image\u003e\n      \u003cenclosure url=\"http://example.com/podcast.m4a\" length=\"8727310\" type=\"audio/x-m4a\"/\u003e\n      \u003cguid\u003ehttp://example.com/archive/aae20050615.m4a\u003c/guid\u003e\n      \u003cpubDate\u003eWed, 15 Jun 2011 19:00:00 GMT\u003c/pubDate\u003e\n      \u003citunes:duration\u003e7:04\u003c/itunes:duration\u003e\n      \u003citunes:keywords\u003esalt, pepper, shaker, exciting\u003c/itunes:keywords\u003e\n    \u003c/item\u003e\n    \u003citem\u003e\n      \u003ctitle\u003ePodcast2 Title\u003c/title\u003e\n      \u003citunes:author\u003eAuthor2\u003c/itunes:author\u003e\n      \u003citunes:subtitle\u003eSubtitle2\u003c/itunes:subtitle\u003e\n      \u003citunes:summary\u003eSummary2\u003c/itunes:summary\u003e\n      \u003citunes:image\u003eimage2.jpg\u003c/itunes:image\u003e\n      \u003cenclosure url=\"http://example.com/podcast2.m4a\" length=\"655555\" type=\"audio/x-m4a\"/\u003e\n      \u003cguid\u003ehttp://example.com/archive/aae2.m4a\u003c/guid\u003e\n      \u003cpubDate\u003eWed, 15 Jul 2011 19:00:00 GMT\u003c/pubDate\u003e\n      \u003citunes:duration\u003e11:20\u003c/itunes:duration\u003e\n      \u003citunes:keywords\u003efoo, bar\u003c/itunes:keywords\u003e\n    \u003c/item\u003e\n  \u003c/channel\u003e\n\u003c/rss\u003e\n```\n\n#### Example 11: Custom filter for XML entities, or whatever\n\n```javascript\nconst xmlOptions = {\n    contentReplacements: {\n        '\u003c': '\u0026lt;',\n        '\u003e': '\u0026gt;',\n        '\"': '\u0026quot;',\n        \"'\": '\u0026apos;',\n        '\u0026': '\u0026amp;'\n    }\n};\n\ntoXML(\n    {\n        foo: '\u003ca\u003e',\n        bar: '\"b\"',\n        baz: \"'\u0026whee'\"\n    },\n    xmlOptions\n);\n```\n\nOutput:\n\n```\n\u003cfoo\u003e\u0026lt;a\u0026gt;\u003c/foo\u003e\u003cbar\u003e\u0026quot;b\u0026quot;\u003c/bar\u003e\u003cbaz\u003e\u0026apos;\u0026amp;whee\u0026apos;\u003c/baz\u003e\n```\n\n#### Example 11b: Custom filter for XML attributes\n\n```javascript\nconst xmlOptions = {\n    attributeReplacements: {\n        '\u003c': '\u0026lt;',\n        '\u003e': '\u0026gt;',\n        '\"': '\u0026quot;',\n        \"'\": '\u0026apos;',\n        '\u0026': '\u0026amp;'\n    }\n};\n\ntoXML(\n    {\n        _name: 'foo',\n        _attrs: { a: '\u003c\"\\'\u0026\"foo\u003e' }\n    },\n    xmlOptions\n);\n```\n\nOutput:\n\n```\n\u003cfoo a=\"\u0026lt;\u0026quot;\u0026apos;\u0026amp;\u0026quot;foo\u0026gt;\"/\u003e\n```\n\n#### Example 12: Avoiding self-closing tags\n\nIf you don't want self-closing tags, you can pass in a special config option `selfCloseTags`:\n\n```javascript\nconst xmlOptions = {\n    selfCloseTags: false\n};\n\ntoXML(\n    {\n        foo: '',\n        bar: undefined\n    },\n    xmlOptions\n);\n```\n\nOutput:\n\n```\n\u003cfoo\u003e\u003c/foo\u003e\u003cbar\u003ewhee\u003c/bar\u003e\n```\n\n#### Example 13: Custom XML header\n\n```javascript\nconst xmlOptions = {\n    header: '\u003c?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"yes\"?\u003e'\n};\n\ntoXML(\n    {\n        foo: 'bar'\n    },\n    xmlOptions\n);\n```\n\nOutput:\n\n```\n\u003c?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"yes\"?\u003e\u003cfoo\u003ebar\u003c/foo\u003e\u003cfoo2\u003ebar2\u003c/foo2\u003e\n```\n\n#### Example 14: Emoji attribute support (needed for AMP)\n\n```javascript\ntoXML({\n    html: {\n        _attrs: {\n            '⚡': true\n        }\n    }\n});\n```\n\nOutput:\n\n```\n\u003chtml ⚡/\u003e\n```\n\n#### Example 15: Duplicate attribute key support\n\n```javascript\ntoXML({\n    html: {\n        _attrs: [\n            {\n                lang: 'en'\n            },\n            {\n                lang: 'klingon'\n            }\n        ]\n    }\n});\n```\n\nOutput:\n\n```\n\u003chtml lang=\"en\" lang=\"klingon\"/\u003e\n```\n\n#### Example 16: XML comments\n\n```javascript\ntoXML(\n    {\n        _comment: 'Some important comment',\n        a: {\n            b: [1, 2, 3]\n        }\n    },\n    { indent: '    ' }\n);\n```\n\nOutput:\n\n```\n\u003c!-- Some important comment --\u003e\n\u003ca\u003e\n    \u003cb\u003e1\u003c/b\u003e\n    \u003cb\u003e2\u003c/b\u003e\n    \u003cb\u003e3\u003c/b\u003e\n\u003c/a\u003e\n```\n\n#### Example 17: Multiple XML comments\n\n```javascript\ntoXML(\n    [\n        { _comment: 'Some important comment' },\n        { _comment: 'This is a very long comment!' },\n        { _comment: 'More important exposition!' },\n        { a: { b: [1, 2, 3] } }\n    ],\n    { indent: '    ' }\n);\n```\n\nOutput:\n\n```\n\u003c!-- Some important comment --\u003e\n\u003c!-- This is a very long comment! --\u003e\n\u003c!-- More important exposition! --\u003e\n\u003ca\u003e\n    \u003cb\u003e1\u003c/b\u003e\n    \u003cb\u003e2\u003c/b\u003e\n    \u003cb\u003e3\u003c/b\u003e\n\u003c/a\u003e\n```\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidcalhoun%2Fjstoxml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidcalhoun%2Fjstoxml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidcalhoun%2Fjstoxml/lists"}