{"id":28166568,"url":"https://github.com/daniel-sc/xml-trueformat","last_synced_at":"2025-07-04T10:34:25.635Z","repository":{"id":279233331,"uuid":"938095494","full_name":"daniel-sc/xml-trueformat","owner":"daniel-sc","description":"Typescript XML parser that 100% retains all formatting for creating identical XML on roundtrips","archived":false,"fork":false,"pushed_at":"2025-06-16T12:04:05.000Z","size":117,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-19T22:14:28.215Z","etag":null,"topics":["typescript","xml","xml-parser"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/daniel-sc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2025-02-24T12:16:07.000Z","updated_at":"2025-06-16T12:00:59.000Z","dependencies_parsed_at":"2025-02-27T12:14:02.565Z","dependency_job_id":null,"html_url":"https://github.com/daniel-sc/xml-trueformat","commit_stats":null,"previous_names":["daniel-sc/xml-integrity","daniel-sc/xml-trueformat"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/daniel-sc/xml-trueformat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel-sc%2Fxml-trueformat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel-sc%2Fxml-trueformat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel-sc%2Fxml-trueformat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel-sc%2Fxml-trueformat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daniel-sc","download_url":"https://codeload.github.com/daniel-sc/xml-trueformat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniel-sc%2Fxml-trueformat/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260838728,"owners_count":23070618,"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":["typescript","xml","xml-parser"],"created_at":"2025-05-15T13:13:27.526Z","updated_at":"2025-07-04T10:34:25.609Z","avatar_url":"https://github.com/daniel-sc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/xml-trueformat)](https://www.npmjs.com/package/xml-trueformat)\n[![Coverage Status](https://coveralls.io/repos/github/daniel-sc/xml-trueformat/badge.svg?branch=main)](https://coveralls.io/github/daniel-sc/xml-trueformat?branch=main)\n\n# xml-trueformat\n\nTypescript XML parser that 100% retains all formatting for creating identical XML on roundtrips.\n\nIf you have an XML file that you want to read, modify, and write back, this library will ensure that the output XML is formatted identical to the input XML.\n\nCheck out the following [blog post](https://dev.to/danielsc/deep-dive-xml-trueformat-preserve-xml-formatting-with-ease-46f5) for more details.\n\n## Features\n\n- Retains all whitespace and line endings\n- Retains all comments\n- Retains whether an element is self-closing or not\n- Retains attributes in the order they were defined\n- Retains attribute quotes (single or double) and whitespace before and after the attribute name\n- Retains XML processing instructions (including the XML declaration)\n- Retains CDATA sections\n- Parses Angular templates and other HTML/XML-like files\n\n## Example\n\nThe following XML:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003croot\u003e\n  \u003c!-- my comment --\u003e\n  \u003cself-closing attribute=\"value with double quotes\" /\u003e\n  \u003cnon-self-closing attribute='value with single quotes'\u003e\u003c/non-self-closing\u003e\n  \u003celement-with-cdata\u003e\u003c![CDATA[\u003chtml\u003e]]\u003e\u003c/element-with-cdata\u003e\n\u003c/root\u003e\n```\n\nWill get parsed by `XmlParser.parse(..)` to:\n\n\u003c!-- prettier-ignore-start --\u003e\n```ts\nnew XmlDocument([\n  new XmlProcessing('xml', ' ', 'version=\"1.0\" encoding=\"UTF-8\"'),\n  new XmlText('\\n'),\n  new XmlElement('root', [], [\n    new XmlText('\\n  '),\n    new XmlComment(' my comment '),\n    new XmlText('\\n  '),\n    new XmlElement('self-closing', [new XmlAttribute('attribute', 'value with double quotes')], [], ' ', true),\n    new XmlText('\\n  '),\n    new XmlElement('non-self-closing', [new XmlAttribute('attribute', 'value with single quotes', ' ', '', '', \"'\")], [], '', false),\n    new XmlText('\\n  '),\n    new XmlElement('element-with-cdata', [], [new XmlCData('\u003chtml\u003e')]),\n    new XmlText('\\n')\n  ])\n]);\n```\n\u003c!-- prettier-ignore-end --\u003e\n\nAnd serializing this again with `XmlDocument.toString()` will exactly give the original XML!\n\n## Development\n\nThis project is written in Typescript and uses Bun.\n\n```bash\nbun install\nbun test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniel-sc%2Fxml-trueformat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaniel-sc%2Fxml-trueformat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniel-sc%2Fxml-trueformat/lists"}