{"id":37200097,"url":"https://github.com/purelabio/xt","last_synced_at":"2026-01-14T23:01:39.359Z","repository":{"id":57569517,"uuid":"344715794","full_name":"purelabio/xt","owner":"purelabio","description":"Missing feature of Go's `encoding/xml`: generic representation of arbitrary XML docs and nodes, reversible, with JSON support.","archived":false,"fork":false,"pushed_at":"2021-03-05T06:31:31.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-20T11:16:05.382Z","etag":null,"topics":["golang","xml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/purelabio.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}},"created_at":"2021-03-05T06:25:47.000Z","updated_at":"2021-03-05T06:38:39.000Z","dependencies_parsed_at":"2022-08-23T17:40:10.819Z","dependency_job_id":null,"html_url":"https://github.com/purelabio/xt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/purelabio/xt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purelabio%2Fxt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purelabio%2Fxt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purelabio%2Fxt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purelabio%2Fxt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/purelabio","download_url":"https://codeload.github.com/purelabio/xt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purelabio%2Fxt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28437916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T22:37:52.437Z","status":"ssl_error","status_checked_at":"2026-01-14T22:37:31.496Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang","xml"],"created_at":"2026-01-14T23:01:38.748Z","updated_at":"2026-01-14T23:01:39.313Z","avatar_url":"https://github.com/purelabio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Overview\n\n**X**ML **T**ypes. Missing feature of the `encoding/xml` package: generic representation of arbitrary XML documents and nodes, mostly-reversible, with JSON support.\n\n* Decodes arbitrary XML with minimal information loss.\n* Encodes back into XML, not identical but equivalent to original.\n* Encodes and decodes as JSON with no information loss.\n\nSmall and dependency-free. The dependencies in `go.mod` are test-only.\n\nSee API docs at https://pkg.go.dev/github.com/purelabio/xt.\n\n## Usage\n\nThis example will decode an XML, re-encode as XML, encode as JSON.\n\n```golang\nimport (\n  \"bytes\"\n  \"encoding/json\"\n  \"encoding/xml\"\n  \"os\"\n\n  \"github.com/purelabio/xt\"\n)\n\nfunc main() {\n  var nodes xt.Nodes\n  err := nodes.Decode(xml.NewDecoder(bytes.NewReader(src)))\n  if err != nil {\n    panic(err)\n  }\n\n  err = xml.NewEncoder(os.Stdout).Encode(nodes)\n  if err != nil {\n    panic(err)\n  }\n\n  err = json.NewEncoder(os.Stdout).Encode(nodes)\n  if err != nil {\n    panic(err)\n  }\n}\n\nvar src = []byte(`\u003c?xml version=\"1.0\"?\u003e\n\u003cone two=\"three\"\u003e\n  four\n\u003c/one\u003e\n`)\n```\n\nResulting data structure:\n\n```golang\nxt.Nodes{\n  xt.Pi{Target: \"xml\", Content: \"version=\\\"1.0\\\"\"},\n  xt.Text(\"\\n\"),\n  xt.Elem{\n    Name: xt.Name{Local: \"one\"},\n    Attrs: []xt.Attr{\n      {Name: xt.Name{Local: \"two\"}, Value: \"three\"},\n    },\n    Nodes: xt.Nodes{\n      xt.Text(\"\\n  four\\n\"),\n    },\n  },\n  xt.Text(\"\\n\"),\n}\n```\n\n## Limitations\n\n* Limitation of `encoding/xml`: doesn't preserve short namespace prefixes. When serializing, it inlines `xmlns` attributes everywhere. The resulting XML should be semantically equivalent to the original, even if the representation is different.\n\n* Limitation of `encoding/xml`: doesn't preserve `\u003c![CDATA[]]\u003e`. All text is serialized as regular text, using escape sequences as appropriate. Again, the result should be semantically equivalent to the original.\n\n* Support for token streaming is limited. `DecodeToken` can decode non-element nodes one-by-one, but always consumes and allocates the entire content of an element, without the ability to \"step in\" and \"step out\".\n\n## License\n\nhttps://unlicense.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurelabio%2Fxt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurelabio%2Fxt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurelabio%2Fxt/lists"}