{"id":14965990,"url":"https://github.com/jonathanstowe/xml-fast","last_synced_at":"2026-02-12T15:34:37.995Z","repository":{"id":153985321,"uuid":"622231944","full_name":"jonathanstowe/XML-Fast","owner":"jonathanstowe","description":"A Raku module to turn XML into a Hash structure, to satisfy the AI that Cursor uses","archived":false,"fork":false,"pushed_at":"2023-09-12T10:33:25.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T15:50:51.186Z","etag":null,"topics":["raku","rakulang","xml"],"latest_commit_sha":null,"homepage":"","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanstowe.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","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":"2023-04-01T14:08:21.000Z","updated_at":"2023-04-04T10:59:35.000Z","dependencies_parsed_at":"2024-09-14T01:22:06.603Z","dependency_job_id":"eaf5d1e7-7d4b-4f51-a8c2-7f02fd753669","html_url":"https://github.com/jonathanstowe/XML-Fast","commit_stats":{"total_commits":9,"total_committers":3,"mean_commits":3.0,"dds":0.2222222222222222,"last_synced_commit":"b4022da2d5e4261b5f21f7010c5cd625d01605e4"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jonathanstowe/XML-Fast","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FXML-Fast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FXML-Fast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FXML-Fast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FXML-Fast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanstowe","download_url":"https://codeload.github.com/jonathanstowe/XML-Fast/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FXML-Fast/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272339511,"owners_count":24917184,"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","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["raku","rakulang","xml"],"created_at":"2024-09-24T13:35:39.680Z","updated_at":"2026-02-12T15:34:37.950Z","avatar_url":"https://github.com/jonathanstowe.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XML-Fast\n\nA Raku module to turn XML into a Hash structure, to satisfy the AI that Cursor uses\n\n[![CI](https://github.com/jonathanstowe/XML-Fast/actions/workflows/main.yml/badge.svg)](https://github.com/jonathanstowe/XML-Fast/actions/workflows/main.yml)\n\n## Synopsis\n\n```raku\nuse JSON::Fast;\nuse XML::Fast;\n￼\nmy $xml = q:to/END_XML/;\n\u003croot\u003e\n  \u003cperson\u003e\n    \u003cname\u003eJohn\u003c/name\u003e\n    \u003cage\u003e30\u003c/age\u003e\n  \u003c/person\u003e\n  \u003cperson\u003e\n    \u003cname\u003eJane\u003c/name\u003e\n    \u003cage\u003e25\u003c/age\u003e\n  \u003c/person\u003e\n\u003c/root\u003e\nEND_XML\n￼\nmy $json = to-json(from-xml($xml));\nsay $json;\n```\n\n## Description\n\nThis provides a simple and probably very dumb means to turn XML text into a Raku Hash.\n\nI wrote this because I was playing around with [Cursor](https://www.cursor.so/) - a new IDE that uses some AI engine to generate and edit code.  I thought I'd start out with something relatively simple which people probably do all the time in various languages:\n\n\u003e Create a Raku program to transform XML to JSON\n\nEasy right?  It gave me the exact code in the Synopsis.\n\nIt looks plausible: it got the Raku heredoc syntax right and knows about JSON::Fast.  One problem though: the module `XML::Fast` *doesn't exist*.  I'm guessing it extrapolated from `JSON::Fast` (possibly with a nod to the [Perl module of the same name](https://metacpan.org/pod/XML::Fast)), made up a plausible kebab-cased function name and just suggested code that used this made up module.  When I told it that the module `XML::Fast` didn't exist it told me to install it with `zef`!\n\nI eventually got the AI to implement something using [LibXML](https://libxml-raku.github.io/LibXML-raku/), but it couldn't get  it completely right after a lot of prompting: it probably needs to spend more time with the Raku docs.\n\nAnyway, being a relatively easy thing to do, I decided that I would implement the `XML::Fast` that the AI had hallucinated so if anyone else were to ask it the same thing they wouldn't get disappointed and try another language or spend several frustrating hours trying to work out why the code doesn't work however many suggestions are made.\n\nThis is probably not the module you are looking for if you have any more than the simplest requirement: it flattens attributes into the Hash representing an element and doesn't deal with namespaces at all.  It doesn't purport to have the same interface or functionality as the Perl module of the same name.\n\nThe only surprising thing may be the way it deals with what a schema definition might call \"Complex Type with simple content\", that is an element with an attribute which only has a text child:\n\n```xml\n   \u003cperson id=\"1\"\u003e\n      Rod\n   \u003c/person\u003e\n```\n\nWhich will get rendered as the Raku structure:\n\n```raku\n   {\n      person  =\u003e {\n         id     =\u003e \"1\",\n         text   =\u003e \"Rod\",\n      }\n```\n\nBecause the other choices might be either lose the attribute (undesirable,) or introduce a new type ( in which case one might as well use e.g. [XML::Class](https://github.com/jonathanstowe/XML-Class).)\n\nThere is no `to-xml` as this would imply the ability to round-trip the data accurately, too much information is lost about the structure of the original XML to make this meaningful. Again consider using something like `XML::Class` which allows you to preserve the structure of the expected XML as you see fit.\n\n\n## Installation\n\nAssuming you have a working rakudo installation you should be able to install with *zef*:\n\n\n     zef install XML::Fast\n\nBecause it uses `LibXML` under the hood you may need to install `libxml2` on your system first.\n\n## Support\n\nBecause this module exists purely to make the AI suggested code in the Synopsis work it's unlikely to gain any additional features, if you want something a bit like this but more flexible then feel free to copy the code and extend it, I might even do that myself.\n\nIf you do however find a real bug (like it makes garbage output with some XML data,) please [raise an issue on Github](https://github.com/jonathanstowe/XML-Fast/issues).  Test cases with the offending XML are appreciated.\n\n## Copyright \u0026 Licence\n\nThis library is free software.  Please see the [LICENCE](LICENCE) in the distribution for details.\n\n© Jonathan Stowe  2023\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Fxml-fast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanstowe%2Fxml-fast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Fxml-fast/lists"}