{"id":15707714,"url":"https://github.com/psychollama/xml-parser","last_synced_at":"2025-03-30T16:20:10.430Z","repository":{"id":92782347,"uuid":"162035373","full_name":"PsychoLlama/xml-parser","owner":"PsychoLlama","description":"An XML parser written for the fun of it","archived":false,"fork":false,"pushed_at":"2018-12-16T19:57:08.000Z","size":88,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T17:58:58.119Z","etag":null,"topics":["combinator","parser","xml"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PsychoLlama.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-12-16T19:50:15.000Z","updated_at":"2020-02-01T20:30:55.000Z","dependencies_parsed_at":"2023-04-13T16:15:47.667Z","dependency_job_id":null,"html_url":"https://github.com/PsychoLlama/xml-parser","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/PsychoLlama%2Fxml-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PsychoLlama%2Fxml-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PsychoLlama%2Fxml-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PsychoLlama%2Fxml-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PsychoLlama","download_url":"https://codeload.github.com/PsychoLlama/xml-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246343252,"owners_count":20762004,"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":["combinator","parser","xml"],"created_at":"2024-10-03T20:41:11.469Z","updated_at":"2025-03-30T16:20:10.412Z","avatar_url":"https://github.com/PsychoLlama.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XML parser\n\nI made this purely for fun. If you're wondering \"Who writes an XML parser for fun?\" well... me. I do.\n\nI've been playing with parsers lately and wanted an excuse to try out the [Parsimmon](https://github.com/jneen/parsimmon/) parser combinator library on a non-trivial language grammar. Spoilers: it's awesome.\n\nTo be clear though: I have no intention of further developing or maintaining this project. It was just an experiment.\n\n## Local usage\nInstall \u0026 compile the program, then point it to an XML-style file.\n```sh\n$ yarn install\n$ yarn build\n$ ./dist/index.js ./path/to/file.xml\n```\n\nTested mostly with XML datasets and SVG graphics. For example, this SVG:\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003csvg width=\"52px\" height=\"52px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\u003e\n  \u003ccircle\n    cx=\"26\"\n    cy=\"26\"\n    r=\"25\"\n    fill=\"#202B33\"\n    stroke=\"#F14981\"\n    stroke-width=\"2\" /\u003e\n\u003c/svg\u003e\n```\n\nGenerates the following Abstract Syntax Tree ([AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree)):\n```json\n{\n  \"declaration\": {\n    \"version\": \"1.0\",\n    \"encoding\": \"UTF-8\"\n  },\n  \"root\": {\n    \"name\": \"svg\",\n    \"ns\": null,\n    \"attributes\": {\n      \"width\": {\n        \"value\": \"52px\",\n        \"property\": \"width\",\n        \"ns\": null\n      },\n      \"height\": {\n        \"value\": \"52px\",\n        \"property\": \"height\",\n        \"ns\": null\n      },\n      \"xmlns\": {\n        \"value\": \"http://www.w3.org/2000/svg\",\n        \"property\": \"xmlns\",\n        \"ns\": null\n      },\n      \"xmlns:xlink\": {\n        \"value\": \"http://www.w3.org/1999/xlink\",\n        \"property\": \"xlink\",\n        \"ns\": \"xmlns\"\n      }\n    },\n    \"children\": [\n      {\n        \"name\": \"circle\",\n        \"ns\": null,\n        \"attributes\": {\n          \"cx\": {\n            \"value\": \"26\",\n            \"property\": \"cx\",\n            \"ns\": null\n          },\n          \"cy\": {\n            \"value\": \"26\",\n            \"property\": \"cy\",\n            \"ns\": null\n          },\n          \"r\": {\n            \"value\": \"25\",\n            \"property\": \"r\",\n            \"ns\": null\n          },\n          \"fill\": {\n            \"value\": \"#202B33\",\n            \"property\": \"fill\",\n            \"ns\": null\n          },\n          \"stroke\": {\n            \"value\": \"#F14981\",\n            \"property\": \"stroke\",\n            \"ns\": null\n          },\n          \"stroke-width\": {\n            \"value\": \"2\",\n            \"property\": \"stroke-width\",\n            \"ns\": null\n          }\n        },\n        \"children\": []\n      }\n    ]\n  }\n}\n```\n\nWhere each tag has a `name`, `attributes` set, array of `children` (possibly containing more tags), and an optional XML namespace. If the document contains an XML declaration (`\u003c?xml ... ?\u003e`) then the metadata is stored in `document.declaration`.\n\nSo to summarize, [Parsimmon](https://github.com/jneen/parsimmon/) is cool and you should try it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsychollama%2Fxml-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsychollama%2Fxml-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsychollama%2Fxml-parser/lists"}