1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | XPath ==== [![GoDoc](https://godoc.org/github.com/antchfx/xpath?status.svg)](https://godoc.org/github.com/antchfx/xpath) [![Coverage Status](https://coveralls.io/repos/github/antchfx/xpath/badge.svg?branch=master)](https://coveralls.io/github/antchfx/xpath?branch=master) [![Build Status](https://travis-ci.org/antchfx/xpath.svg?branch=master)](https://travis-ci.org/antchfx/xpath) [![Go Report Card](https://goreportcard.com/badge/github.com/antchfx/xpath)](https://goreportcard.com/report/github.com/antchfx/xpath) XPath is Go package provides selecting nodes from XML, HTML or other documents using XPath expression. Implementation === - [htmlquery](https://github.com/antchfx/htmlquery) - an XPath query package for HTML document - [xmlquery](https://github.com/antchfx/xmlquery) - an XPath query package for XML document. - [jsonquery](https://github.com/antchfx/jsonquery) - an XPath query package for JSON document Supported Features === #### The basic XPath patterns. > The basic XPath patterns cover 90% of the cases that most stylesheets will need. - `node` : Selects all child elements with nodeName of node. - `*` : Selects all child elements. - `@attr` : Selects the attribute attr. - `@*` : Selects all attributes. - `node()` : Matches an org.w3c.dom.Node. - `text()` : Matches a org.w3c.dom.Text node. - `comment()` : Matches a comment. - `.` : Selects the current node. - `..` : Selects the parent of current node. - `/` : Selects the document node. - `a[expr]` : Select only those nodes matching a which also satisfy the expression expr. - `a[n]` : Selects the nth matching node matching a When a filter's expression is a number, XPath selects based on position. - `a/b` : For each node matching a, add the nodes matching b to the result. - `a//b` : For each node matching a, add the descendant nodes matching b to the result. - `//b` : Returns elements in the entire document matching b. - `a|b` : All nodes matching a or b, union operation(not boolean or). - `(a, b, c)` : Evaluates each of its operands and concatenates the resulting sequences, in order, into a single result sequence #### Node Axes - `child::*` : The child axis selects children of the current node. - `descendant::*` : The descendant axis selects descendants of the current node. It is equivalent to '//'. - `descendant-or-self::*` : Selects descendants including the current node. - `attribute::*` : Selects attributes of the current element. It is equivalent to @* - `following-sibling::*` : Selects nodes after the current node. - `preceding-sibling::*` : Selects nodes before the current node. - `following::*` : Selects the first matching node following in document order, excluding descendants. - `preceding::*` : Selects the first matching node preceding in document order, excluding ancestors. - `parent::*` : Selects the parent if it matches. The '..' pattern from the core is equivalent to 'parent::node()'. - `ancestor::*` : Selects matching ancestors. - `ancestor-or-self::*` : Selects ancestors including the current node. - `self::*` : Selects the current node. '.' is equivalent to 'self::node()'. #### Expressions The gxpath supported three types: number, boolean, string. - `path` : Selects nodes based on the path. - `a = b` : Standard comparisons. * a = b True if a equals b. * a != b True if a is not equal to b. * a < b True if a is less than b. * a <= b True if a is less than or equal to b. * a > b True if a is greater than b. * a >= b True if a is greater than or equal to b. - `a + b` : Arithmetic expressions. * `- a` Unary minus * a + b Add * a - b Substract * a * b Multiply * a div b Divide * a mod b Floating point mod, like Java. - `a or b` : Boolean `or` operation. - `a and b` : Boolean `and` operation. - `(expr)` : Parenthesized expressions. - `fun(arg1, ..., argn)` : Function calls: | Function | Supported | | --- | --- | `boolean()`| ✓ | `ceiling()`| ✓ | `choose()`| ✗ | `concat()`| ✓ | `contains()`| ✓ | `count()`| ✓ | `current()`| ✗ | `document()`| ✗ | `element-available()`| ✗ | `ends-with()`| ✓ | `false()`| ✓ | `floor()`| ✓ | `format-number()`| ✗ | `function-available()`| ✗ | `generate-id()`| ✗ | `id()`| ✗ | `key()`| ✗ | `lang()`| ✗ | `last()`| ✓ | `local-name()`| ✓ | `matches()`| ✓ | `name()`| ✓ | `namespace-uri()`| ✓ | `normalize-space()`| ✓ | `not()`| ✓ | `number()`| ✓ | `position()`| ✓ | `replace()`| ✓ | `reverse()`| ✓ | `round()`| ✓ | `starts-with()`| ✓ | `string()`| ✓ | `string-length()`| ✓ | `substring()`| ✓ | `substring-after()`| ✓ | `substring-before()`| ✓ | `sum()`| ✓ | `system-property()`| ✗ | `translate()`| ✓ | `true()`| ✓ | `unparsed-entity-url()` | ✗ | Changelogs === 2019-03-19 - optimize XPath `|` operation performance. [#33](https://github.com/antchfx/xpath/issues/33). Tips: suggest split into multiple subquery if you have a lot of `|` operations. 2019-01-29 - improvement `normalize-space` function. [#32](https://github.com/antchfx/xpath/issues/32) 2018-12-07 - supports XPath 2.0 Sequence expressions. [#30](https://github.com/antchfx/xpath/pull/30) by [@minherz](https://github.com/minherz). |
Commit History @935382b7-d7bf-4714-88e7-8c437882a724/main
0
»»
- Update upstream source from tag 'upstream/1.1.8' Dawid Dziurla 3 years ago
- d/changelog: dch Dawid Dziurla 4 years ago
- New upstream version 1.1.4 Dawid Dziurla 4 years ago
- Update upstream source from tag 'upstream/1.1.4' Dawid Dziurla 4 years ago
- d/copyright: delete Files-Excluded Dawid Dziurla 4 years ago
- d/changelog: dch Dawid Dziurla 4 years ago
- Update upstream source from tag 'upstream/1.1.3' Dawid Dziurla 4 years ago
- New upstream version 1.1.3 Dawid Dziurla 4 years ago
- d/changelog: Bump version for source-only upload Stephen Gelman 4 years ago
- d/changelog: Release 1.1.2-1 Stephen Gelman 4 years ago
- d/changelog: close ITP bug Dawid Dziurla 4 years ago
- debianization Dawid Dziurla 4 years ago
- New upstream version 1.1.2 Dawid Dziurla 4 years ago
- Ignore quilt dir .pc via .gitignore Dawid Dziurla 4 years ago
0
»»