{"id":13509762,"url":"https://github.com/nhu313/Quinn","last_synced_at":"2025-03-30T14:31:42.661Z","repository":{"id":18602608,"uuid":"21807572","full_name":"nhu313/Quinn","owner":"nhu313","description":"XML parser for Elixir","archived":false,"fork":false,"pushed_at":"2019-01-25T15:43:22.000Z","size":134,"stargazers_count":49,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T20:02:50.364Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nhu313.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}},"created_at":"2014-07-14T04:42:51.000Z","updated_at":"2024-06-20T04:57:44.000Z","dependencies_parsed_at":"2022-09-26T21:50:38.558Z","dependency_job_id":null,"html_url":"https://github.com/nhu313/Quinn","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhu313%2FQuinn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhu313%2FQuinn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhu313%2FQuinn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhu313%2FQuinn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nhu313","download_url":"https://codeload.github.com/nhu313/Quinn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246332205,"owners_count":20760438,"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-08-01T02:01:12.639Z","updated_at":"2025-03-30T14:31:42.258Z","avatar_url":"https://github.com/nhu313.png","language":"Elixir","funding_links":[],"categories":["XML"],"sub_categories":[],"readme":"Quinn\n=====\n\nA simple XML parser in Elixir aims to parse rss/atom feeds. I'm currently\nusing `xmerl_scan.string` to parse the xml. I'm a bit busy so I may take awhile to response and/or update. Feel free to send a pull request. Otherwise, check out [hex](https://hex.pm/packages?search=xml\u0026sort=downloads) for other XML parsers that may be better maintained.\n\n# Parsing\n\n\n```elixir\nQuinn.parse(\"\u003chead\u003e\u003ctitle short_name = \\\"yah\\\"\u003eYahoo\u003c/title\u003e\u003ctitle:content\u003eBing\u003c/title:content\u003e\u003c/head\u003e\")\n```\nCalling parse on the xml will produce\n```elixir\n[%{attr: [], name: :head,\n   value: [%{attr: [short_name: \"yah\"], name: :title, value: [\"Yahoo\"]},\n           %{attr: [], name: :\"title:content\", value: [\"Bing\"]}]}]\n```\n### Parsing without namespaces(key prefix)\n```elixir\nxml = \"\u003cm:return xsi:type=\"d4p1:Answer\"\u003e\n      \u003cd4p1:Title\u003e Title \u003c/d4p1:Title\u003e\n      \u003cd4p1:Description\u003e Description \u003c/d4p1:Description\u003e\n     \u003c/m:return\u003e\"\n\nQuinn.parse(xml, %{strip_namespaces: true})\n```\n\nCalling parse on the xml will produce\n```elixir\n[%{attr: [\"xsi:type\": \"d4p1:Answer\"],\n   name: :return,\n   value: [%{attr: [], name: :title, value: [\"Title\"]},\n%{attr: [], name: :description, value: [\"Description\"]}]}]\n```\n\n### Parsing comments\n```elixir\nxml = ~s(\u003chead\u003e\u003ctitle short_name = \"yah\"\u003eYahoo\u003c/title\u003e\u003c!--- \u003ctest pattern=\"SECAM\" /\u003e\u003ctest pattern=\"NTSC\" /\u003e --\u003e\u003c/head\u003e)\nresult = Quinn.parse(xml, %{comments: true})\n```\nThe xml above will give you this. Note the name is `comments`.\n\n```elixir\n[%{attr: [],\n   name: :head,\n   value: [%{attr: [short_name: \"yah\"], name: :title, value: [\"Yahoo\"]},\n           %{attr: [], name: :comments, value: ~s(- \u003ctest pattern=\"SECAM\" /\u003e\u003ctest pattern=\"NTSC\" /\u003e)}]}]\n```\n\n### Parsing - Attributes as map\n```elixir\nxml = ~s(\u003cm:return xsi:type=\"d4p1:Answer\" desc=\"bla\"\u003e\u003cd4p1:Title\u003e Title \u003c/d4p1:Title\u003e\u003cd4p1:Description\u003e Description \u003c/d4p1:Description\u003e\u003c/m:return\u003e)\n\nresult = Quinn.parse(xml, %{map_attributes: true})\n```\n\nThe xml above will give you the attributes in map\n\n```\n\t    expected = [%{attr: %{\"xsi:type\": \"d4p1:Answer\", desc: \"bla\"},\n\t                  name: :\"m:return\",\n\t                  value: [%{attr: %{}, name: :\"d4p1:Title\", value: [\"Title\"]},\n\t                %{attr: %{},\n\t                  name: :\"d4p1:Description\",\n\t                  value: [\"Description\"]}]}]\n```\n\t\n# Finding nodes\n\nSuppose you want to find all the body nodes from this structure:\n```elixir\nstructure = %{attr: [],\n              name: :html,\n              value: [%{attr: [], name: :head, value: [\"title\"]},\n                      %{attr: [], name: :title, value: []},\n                      %{attr: [], name: :body, value: [\"body1\", \"body2\"]},\n                      %{attr: [], name: :footer, value: [%{attr: [], name: :line, value: [\"this\"]}]},\n                      %{attr: [], name: :body, value: [%{attr: [], name: :line, value: [\"that\"]}]},\n                      %{attr: [], name: :\"content:encoded\", value: [\"\u003cp\u003ecomet!!\u003c/p\u003e\"]}]}\n```\nYou can call\n```elixir\nQuinn.find(structure, :body)\n```\nThis will be the result:\n```elixir\n[%{attr: [], name: :body, value: [\"body1\", \"body2\"]},\n %{attr: [], name: :body, value: [%{attr: [], name: :line, value: [\"that\"]}]}]\n```\nOr given the structure above, you want to find the node `line` inside `body`, then you can invoke it like this:\n```elixir\nQuinn.find(structure, [:body, :line])\n```\nThe result will be\n```elixir\n[%{attr: [], name: :line, value: [\"that\"]}]\n```\nPlease refer to the tests if you want to see more example on how it is used.\n\nPlease let me know if you come across any problem. I'm still new to Elixir so feel free to contribute or clean up the code.\n\n# License\nQuinn source code is released under Apache 2 License. Check LICENSE file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhu313%2FQuinn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhu313%2FQuinn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhu313%2FQuinn/lists"}