{"id":13693668,"url":"https://github.com/antchfx/xpath","last_synced_at":"2026-02-23T09:12:29.930Z","repository":{"id":37548654,"uuid":"70380104","full_name":"antchfx/xpath","owner":"antchfx","description":"XPath package for Golang, supports HTML, XML, JSON document query.","archived":false,"fork":false,"pushed_at":"2025-04-21T13:36:04.000Z","size":246,"stargazers_count":709,"open_issues_count":14,"forks_count":90,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-21T14:49:47.783Z","etag":null,"topics":["go","go-xml","golang","html","selects-descendants","xml","xpath","xpath-patterns","xpath-query","xpath2"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antchfx.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-10-09T05:51:24.000Z","updated_at":"2025-04-21T13:36:08.000Z","dependencies_parsed_at":"2024-06-18T11:19:53.703Z","dependency_job_id":"ac96bd22-930f-4946-9d03-4de2d635c100","html_url":"https://github.com/antchfx/xpath","commit_stats":{"total_commits":178,"total_committers":20,"mean_commits":8.9,"dds":0.2696629213483146,"last_synced_commit":"4b4638b370e898a9d10709464b8cd460b7dcfd0c"},"previous_names":["antchfx/gxpath"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antchfx%2Fxpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antchfx%2Fxpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antchfx%2Fxpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antchfx%2Fxpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antchfx","download_url":"https://codeload.github.com/antchfx/xpath/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250514752,"owners_count":21443208,"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":["go","go-xml","golang","html","selects-descendants","xml","xpath","xpath-patterns","xpath-query","xpath2"],"created_at":"2024-08-02T17:01:15.096Z","updated_at":"2026-02-23T09:12:24.898Z","avatar_url":"https://github.com/antchfx.png","language":"Go","readme":"# XPath\n\n[![GoDoc](https://godoc.org/github.com/antchfx/xpath?status.svg)](https://godoc.org/github.com/antchfx/xpath)\n[![Coverage Status](https://coveralls.io/repos/github/antchfx/xpath/badge.svg?branch=master)](https://coveralls.io/github/antchfx/xpath?branch=master)\n[![Build Status](https://github.com/antchfx/xpath/actions/workflows/testing.yml/badge.svg)](https://github.com/antchfx/xpath/actions/workflows/testing.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/antchfx/xpath)](https://goreportcard.com/report/github.com/antchfx/xpath)\n\nXPath is Go package provides selecting nodes from XML, HTML or other documents using XPath expression.\n\n# Implementation\n\n- [htmlquery](https://github.com/antchfx/htmlquery) - an XPath query package for HTML document\n\n- [xmlquery](https://github.com/antchfx/xmlquery) - an XPath query package for XML document.\n\n- [jsonquery](https://github.com/antchfx/jsonquery) - an XPath query package for JSON document\n\n# Supported Features\n\n#### The basic XPath patterns.\n\n\u003e The basic XPath patterns cover 90% of the cases that most stylesheets will need.\n\n- `node` : Selects all child elements with nodeName of node.\n\n- `*` : Selects all child elements.\n\n- `@attr` : Selects the attribute attr.\n\n- `@*` : Selects all attributes.\n\n- `node()` : Matches an org.w3c.dom.Node.\n\n- `text()` : Matches a org.w3c.dom.Text node.\n\n- `comment()` : Matches a comment.\n\n- `.` : Selects the current node.\n\n- `..` : Selects the parent of current node.\n\n- `/` : Selects the document node.\n\n- `a[expr]` : Select only those nodes matching a which also satisfy the expression expr.\n\n- `a[n]` : Selects the nth matching node matching a When a filter's expression is a number, XPath selects based on position.\n\n- `a/b` : For each node matching a, add the nodes matching b to the result.\n\n- `a//b` : For each node matching a, add the descendant nodes matching b to the result.\n\n- `//b` : Returns elements in the entire document matching b.\n\n- `a|b` : All nodes matching a or b, union operation(not boolean or).\n\n- `(a, b, c)` : Evaluates each of its operands and concatenates the resulting sequences, in order, into a single result sequence\n\n- `(a/b)` : Selects all matches nodes as grouping set.\n\n#### Node Axes\n\n- `child::*` : The child axis selects children of the current node.\n\n  - `child::node()`: Selects all the children of the context node.\n  - `child::text()`: Selects all text node children of the context node.\n\n- `descendant::*` : The descendant axis selects descendants of the current node. It is equivalent to '//'.\n\n- `descendant-or-self::*` : Selects descendants including the current node.\n\n- `attribute::*` : Selects attributes of the current element. It is equivalent to @\\*\n\n- `following-sibling::*` : Selects nodes after the current node.\n\n- `preceding-sibling::*` : Selects nodes before the current node.\n\n- `following::*` : Selects the first matching node following in document order, excluding descendants.\n\n- `preceding::*` : Selects the first matching node preceding in document order, excluding ancestors.\n\n- `parent::*` : Selects the parent if it matches. The '..' pattern from the core is equivalent to 'parent::node()'.\n\n- `ancestor::*` : Selects matching ancestors.\n\n- `ancestor-or-self::*` : Selects ancestors including the current node.\n\n- `self::*` : Selects the current node. '.' is equivalent to 'self::node()'.\n\n#### Expressions\n\nThe gxpath supported three types: number, boolean, string.\n\n- `path` : Selects nodes based on the path.\n\n- `a = b` : Standard comparisons.\n\n  - `a = b` : True if a equals b.\n  - `a != b` : True if a is not equal to b.\n  - `a \u003c b` : True if a is less than b.\n  - `a \u003c= b` : True if a is less than or equal to b.\n  - `a \u003e b` : True if a is greater than b.\n  - `a \u003e= b` : True if a is greater than or equal to b.\n\n- `a + b` : Arithmetic expressions.\n\n  - `- a` Unary minus\n  - `a + b` : Addition\n  - `a - b` : Subtraction\n  - `a * b` : Multiplication\n  - `a div b` : Division\n  - `a mod b` : Modulus (division remainder)\n\n- `a or b` : Boolean `or` operation.\n\n- `a and b` : Boolean `and` operation.\n\n- `(expr)` : Parenthesized expressions.\n\n- `fun(arg1, ..., argn)` : Function calls:\n\n| Function                | Supported |\n| ----------------------- | --------- |\n| `boolean()`             | ✓         |\n| `ceiling()`             | ✓         |\n| `choose()`              | ✗         |\n| `concat()`              | ✓         |\n| `contains()`            | ✓         |\n| `count()`               | ✓         |\n| `current()`             | ✗         |\n| `document()`            | ✗         |\n| `element-available()`   | ✗         |\n| `ends-with()`           | ✓         |\n| `false()`               | ✓         |\n| `floor()`               | ✓         |\n| `format-number()`       | ✗         |\n| `function-available()`  | ✗         |\n| `generate-id()`         | ✗         |\n| `id()`                  | ✗         |\n| `key()`                 | ✗         |\n| `lang()`                | ✗         |\n| `last()`                | ✓         |\n| `local-name()`          | ✓         |\n| `lower-case()`[^1]      | ✓         |\n| `matches()`             | ✓         |\n| `name()`                | ✓         |\n| `namespace-uri()`       | ✓         |\n| `normalize-space()`     | ✓         |\n| `not()`                 | ✓         |\n| `number()`              | ✓         |\n| `position()`            | ✓         |\n| `replace()`             | ✓         |\n| `reverse()`             | ✓         |\n| `round()`               | ✓         |\n| `starts-with()`         | ✓         |\n| `string()`              | ✓         |\n| `string-join()`[^1]     | ✓         |\n| `string-length()`       | ✓         |\n| `substring()`           | ✓         |\n| `substring-after()`     | ✓         |\n| `substring-before()`    | ✓         |\n| `sum()`                 | ✓         |\n| `system-property()`     | ✗         |\n| `translate()`           | ✓         |\n| `true()`                | ✓         |\n| `unparsed-entity-url()` | ✗         |\n\n[^1]: XPath-2.0 expression\n","funding_links":[],"categories":["XML","Misc","开源类库","Open source library","Go","Libraries for creating HTTP middlewares"],"sub_categories":["创建http中间件的代码库","文本处理","Routers","Word Processing","Utility/Miscellaneous","路由器","高級控制台界面","高级控制台界面"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantchfx%2Fxpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantchfx%2Fxpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantchfx%2Fxpath/lists"}