{"id":18598790,"url":"https://github.com/crazypython/streamingjsxmlparser","last_synced_at":"2025-09-01T12:11:34.997Z","repository":{"id":148713483,"uuid":"395365431","full_name":"CrazyPython/streamingjsxmlparser","owner":"CrazyPython","description":"An efficient XML parser for JS. Unmaintained, incomplete, and probably buggy.","archived":false,"fork":false,"pushed_at":"2021-08-12T15:53:03.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-17T23:49:02.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/CrazyPython.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":"2021-08-12T15:32:36.000Z","updated_at":"2021-08-12T15:53:06.000Z","dependencies_parsed_at":"2023-04-11T09:02:45.587Z","dependency_job_id":null,"html_url":"https://github.com/CrazyPython/streamingjsxmlparser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyPython%2Fstreamingjsxmlparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyPython%2Fstreamingjsxmlparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyPython%2Fstreamingjsxmlparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyPython%2Fstreamingjsxmlparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CrazyPython","download_url":"https://codeload.github.com/CrazyPython/streamingjsxmlparser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544158,"owners_count":22088808,"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":[],"created_at":"2024-11-07T01:34:27.452Z","updated_at":"2025-05-16T14:12:41.673Z","avatar_url":"https://github.com/CrazyPython.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# streamingjsxmlparser\nAn efficient XML parser for JS. Implements part of [the XML specification.](https://www.w3.org/TR/xml/)\n\n* Streaming: This algorithmic optimization makes it several times faster than a typical XML parser.\n\nRationale: This parser does not build a tree, which causes memory allocation and creates GC pressure. Instead, it parses in a stream, looking at it character-by-character. Modern superscalar CPUs are very efficient at those types of operations.\n\n\n## How to use it\n\nStreaming APIs are used by building an internal state and collecting information as you traverse the tree.\n\n### Example\n\n```\nimport { XMLParser } from './xmlparser.mjs'\nclass MyParser extends XMLParser {\n  emitData(data) {\n     console.log(\"Encountered data:\", JSON.stringify(data))\n     this.data = '' // mark data as processed\n  }\n  emitStartTag(name, attributes) {\n     console.log(\"Encountered a start tag:\", name, attributes)\n  }\n  emitEndTag(name) {\n     console.log(\"Encountered an end tag:\", name)\n  }\n}\n```\n\nResults in:\n\n```\nEncountered a start tag: html {}\nEncountered a start tag: head {}\nEncountered a start tag: title {}\nEncountered data: \"Test\"\nEncountered an end tag: title\nEncountered an end tag: head\nEncountered data: \"\\n            \"\nEncountered a start tag: body {}\nEncountered a start tag: h1 { key: 'value' }\nEncountered data: \"This is a heading!\"\nEncountered an end tag: h1\nEncountered an end tag: body\nEncountered an end tag: html\n```\n\n### Tips and tricks\n\nUsing a streaming parser is like writing a for loop over all events. \n\n## Warning\n\nThis is not an HTML parser. HTML is more complex, because it supports features such as:\n\n - Self-closing tags: `\u003cp\u003ea\u003cp\u003eb` turns into `\u003cp\u003ea\u003c/p\u003e\u003cp\u003eb\u003c/p\u003e` because `p` is a self-closing tag.\n - Quoteless attributes: `\u003ch1 class=heading\u003e` works as well as `\u003ch1 class=\"heading\"\u003e`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazypython%2Fstreamingjsxmlparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrazypython%2Fstreamingjsxmlparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazypython%2Fstreamingjsxmlparser/lists"}