{"id":23191118,"url":"https://github.com/olaven/serialize-xml","last_synced_at":"2025-08-18T19:32:12.108Z","repository":{"id":42669861,"uuid":"248868988","full_name":"olaven/serialize-xml","owner":"olaven","description":"Serialize (i.e. stringify) an object into xml string. ","archived":false,"fork":false,"pushed_at":"2023-03-05T19:34:31.000Z","size":444,"stargazers_count":6,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-09T16:51:08.295Z","etag":null,"topics":["deno","xml"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olaven.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["olaven"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-03-20T23:07:03.000Z","updated_at":"2023-03-10T08:11:34.000Z","dependencies_parsed_at":"2023-02-06T07:46:27.580Z","dependency_job_id":null,"html_url":"https://github.com/olaven/serialize-xml","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaven%2Fserialize-xml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaven%2Fserialize-xml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaven%2Fserialize-xml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaven%2Fserialize-xml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olaven","download_url":"https://codeload.github.com/olaven/serialize-xml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229882713,"owners_count":18138875,"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":["deno","xml"],"created_at":"2024-12-18T12:16:17.401Z","updated_at":"2024-12-18T12:16:17.975Z","avatar_url":"https://github.com/olaven.png","language":"TypeScript","funding_links":["https://github.com/sponsors/olaven","https://github.com/sponsors/olaven/"],"categories":[],"sub_categories":[],"readme":"# serialize-xml ![Test](https://github.com/olaven/serialize-xml/workflows/Test/badge.svg) [![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/raw.githubusercontent.com/olaven/serialize-xml/v0.4.0/mod.ts) [![codebeat badge](https://codebeat.co/badges/d8b0bc93-f488-41bb-a251-8a28a8bcd1b9)](https://codebeat.co/projects/github-com-olaven-serialize-xml-master)\n* A simple module for serializing objects to XML. \n* Compatible with [Deno](deno.land) and [NodeJS](https://nodejs.org). \n\nIf you or your company is benefitting from `serialize-xml`, consider becoming a [sponsor](https://github.com/sponsors/olaven/). \nThis way I can work on new features and continue to maintain it worry-free. \n\n## Usage \nThere is _one_ concept to understand:\n* `Tag` - representing a tag, like `\u003cthis\u003e\u003c/this\u003e`\n\n## Examples\n```ts\n                                //\"serialize-xml\" if you're using node \nimport  { serialize, tag } from \"https://raw.githubusercontent.com/olaven/serialize-xml/v0.4.0/mod.ts\"\n\n//\u003cname\u003e\u003c/name\u003e\nconst without_children = serialize(tag(\"name\"))\n//\u003cname\u003echildren\u003c/name\u003e\nconst without_attributes = serialize(tag(\"name\", \"children\"))\n//\u003cname key=\"value\"\u003echildren\u003c/name\u003e\nconst full_tag = serialize(tag(\"name\", \"children\", [[\"key\", \"value\"]]))\n\nconst xml = serialize(\n    tag(\"outer\", \n        [\n            tag(\"inner\", \"content\")\n        ], \n        [\n            [\"key\", \"value\"]\n        ]\n    )\n); \n\n//prints: \u003couter\u003e\u003cinner key=\"value\"\u003econtent\u003c/inner\u003e\u003c/outer\u003e\nconsole.log(\"serialized: \", xml);\n```\n\n### Serialze XML declarations\n```ts                     \n                                        //\"serialize-xml\" if you're using node     \nimport { serialize, declaration } from \"https://raw.githubusercontent.com/olaven/serialize-xml/v0.4.0/mod.ts\"; \nconst xml = serialize(declaration([[\"version\", \"1.0\"]]));\n\n//prints: \u003c?xml version=\"1.0\"?\u003e\nconsole.log(\"serialized declaration\", xml);\n```\n\n### Multiple parents\n```typescript\n\n/*\n    \u003c?xml version=\"1.0\"?\u003e\n    \u003cfirst_parent\u003e\u003c/first_parent\u003e\n    \u003csecond_parent\u003e\n        \u003cchild\u003e\u003c/child\u003e\n    \u003c/second_parent\u003e\n*/\n\nconst xml = serialize(\n    declaration([[\"version\", \"1.0\"]]), \n    tag(\"first_parent\"), \n    tag(\"second_parent\", [\n        tag(\"child\")\n    ])\n); \n```\n\n### Alternatively, build tags by passing an object.  \n```ts\n                            //\"serialize-xml\" if you're using node \nimport  { serialize } from \"https://raw.githubusercontent.com/olaven/serialize-xml/v0.4.0/mod.ts\"\n\nconst xml = serialize({\n    name: \"my_tag_name\", \n    children: [\n        {\n            name: \"sub_tag\", \n            children: \"inner_content_of_tag\", \n            attributes: [\n                [\"attribute_key\", \"attribute_value\"]\n            ]\n        }\n    ],\n    attributes: []\n});\n\n//prints: '\u003cmy_tag_name\u003e\u003csub_tag attribute_key=\"attribute_value\"\u003einner_content_of_tag\u003c/sub_tag\u003e\u003c/my_tag_name\u003e'\nconsole.log(\"serialized: \", xml); \n```\n\n## Escaping \n`serialize-xml` will escape tag values and tag attributes \naccording to [the XML spec](https://www.w3.org/TR/xml/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaven%2Fserialize-xml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folaven%2Fserialize-xml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaven%2Fserialize-xml/lists"}