{"id":35092278,"url":"https://github.com/speedata/cxpath","last_synced_at":"2026-05-18T12:34:51.853Z","repository":{"id":265433028,"uuid":"895451299","full_name":"speedata/cxpath","owner":"speedata","description":"A programmer's friendly interface to XPath","archived":false,"fork":false,"pushed_at":"2026-05-03T10:23:19.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-03T12:22:39.963Z","etag":null,"topics":["golang","xpath","xpath2"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/speedata.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-28T08:32:16.000Z","updated_at":"2026-05-03T10:23:15.000Z","dependencies_parsed_at":"2024-11-29T11:25:54.849Z","dependency_job_id":"602530c5-7d4d-4919-8bf3-938b341c6c98","html_url":"https://github.com/speedata/cxpath","commit_stats":null,"previous_names":["speedata/cxpath"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/speedata/cxpath","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speedata%2Fcxpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speedata%2Fcxpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speedata%2Fcxpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speedata%2Fcxpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/speedata","download_url":"https://codeload.github.com/speedata/cxpath/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speedata%2Fcxpath/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33178337,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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","xpath","xpath2"],"created_at":"2025-12-27T14:59:02.778Z","updated_at":"2026-05-18T12:34:51.848Z","avatar_url":"https://github.com/speedata.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/speedata/cxpath.svg)](https://pkg.go.dev/github.com/speedata/cxpath)\n\n# cxpath - a programmer's friendly interface to XPath\n\nWith cxpath you can access XML files via XPath 2.0 in a Go friendly matter.\n\n```xml\n\u003ca:root xmlns:a=\"anamespace\"\u003e\n  \u003ca:sub\u003etext\u003c/a:sub\u003e\n\u003c/a:root\u003e\n```\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/speedata/cxpath\"\n)\n\nfunc dothings() error {\n\tctx, err := cxpath.NewFromFile(\"myfile.xml\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t// for XPath queries\n\tctx.SetNamespace(\"a\", \"anamespace\")\n\troot := ctx.Root()\n\t// prints 'root'\n\tfmt.Println(root.Eval(\"local-name()\"))\n\t// prints sub\n\tfmt.Println(root.Eval(\"local-name(a:sub)\"))\n\t// prints anamespace\n\tfmt.Println(root.Eval(\"namespace-uri(a:sub)\"))\n\tsub := root.Eval(\"a:sub\")\n\tfor cp := range sub.Each(\"string-to-codepoints(.)\") {\n\t\t// prints 116, 101, 120, 116 - the codepoints for 'text'\n\t\tfmt.Println(cp)\n\t}\n\treturn nil\n}\n\nfunc main() {\n\tif err := dothings(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n\n\n## Error handling\n\nThe constructors `NewFromFile` and `NewFromReader` return errors the usual Go way.\nFor all other methods, errors are stored in the `Error` field of the returned `Context` so that method chaining stays clean:\n\n```go\nroot := ctx.Root()\nresult := root.Eval(\"some/xpath\")\nif result.Error != nil {\n    log.Fatal(result.Error)\n}\nfmt.Println(result.String())\n```\n\nThe same applies to the `Each` iterator. If the XPath expression is invalid, the iterator yields a single `Context` with the `Error` field set:\n\n```go\nfor item := range root.Each(\"some/xpath\") {\n    if item.Error != nil {\n        log.Fatal(item.Error)\n    }\n    fmt.Println(item.Int())\n}\n```\n\nThe value accessors `Int()` and `Bool()` also store conversion errors in `Context.Error` rather than returning them directly.\n\n## Installation\n\n    go get github.com/speedata/cxpath\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspeedata%2Fcxpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspeedata%2Fcxpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspeedata%2Fcxpath/lists"}