Skip to content

Commit a091ad3

Browse files
committed
update README
1 parent bcff0c3 commit a091ad3

File tree

1 file changed

+34
-46
lines changed

1 file changed

+34
-46
lines changed

README.md

+34-46
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ Overview
1212

1313
`htmlquery` built-in the query object caching feature based on [LRU](https://godoc.org/github.com/golang/groupcache/lru), this feature will caching the recently used XPATH query string. Enable query caching can avoid re-compile XPath expression each query.
1414

15+
You can visit this page to learn about the supported XPath(1.0/2.0) syntax. https://github.com/antchfx/xpath
16+
17+
XPath query packages for Go
18+
===
19+
| Name | Description |
20+
| ------------------------------------------------- | ----------------------------------------- |
21+
| [htmlquery](https://github.com/antchfx/htmlquery) | XPath query package for the HTML document |
22+
| [xmlquery](https://github.com/antchfx/xmlquery) | XPath query package for the XML document |
23+
| [jsonquery](https://github.com/antchfx/jsonquery) | XPath query package for the JSON document |
24+
1525
Installation
1626
====
1727

@@ -94,6 +104,30 @@ fmt.Printf("total count is %f", v)
94104
```
95105

96106

107+
Quick Starts
108+
===
109+
110+
```go
111+
func main() {
112+
doc, err := htmlquery.LoadURL("https://www.bing.com/search?q=golang")
113+
if err != nil {
114+
panic(err)
115+
}
116+
// Find all news item.
117+
list, err := htmlquery.QueryAll(doc, "//ol/li")
118+
if err != nil {
119+
panic(err)
120+
}
121+
for i, n := range list {
122+
a := htmlquery.FindOne(n, "//a")
123+
if a != nil {
124+
fmt.Printf("%d %s(%s)\n", i, htmlquery.InnerText(a), htmlquery.SelectAttr(a, "href"))
125+
}
126+
}
127+
}
128+
```
129+
130+
97131
FAQ
98132
====
99133

@@ -124,52 +158,6 @@ BenchmarkDisableSelectorCache-4 500000 3162 ns/op
124158
htmlquery.DisableSelectorCache = true
125159
```
126160

127-
Changelogs
128-
===
129-
130-
2019-11-19
131-
- Add built-in query object cache feature, avoid re-compilation for the same query string. [#16](https://github.com/antchfx/htmlquery/issues/16)
132-
- Added LoadDoc [18](https://github.com/antchfx/htmlquery/pull/18)
133-
134-
2019-10-05
135-
- Add new methods that compatible with invalid XPath expression error: `QueryAll` and `Query`.
136-
- Add `QuerySelector` and `QuerySelectorAll` methods, supported reused your query object.
137-
138-
2019-02-04
139-
- [#7](https://github.com/antchfx/htmlquery/issues/7) Removed deprecated `FindEach()` and `FindEachWithBreak()` methods.
140-
141-
2018-12-28
142-
- Avoid adding duplicate elements to list for `Find()` method. [#6](https://github.com/antchfx/htmlquery/issues/6)
143-
144-
Tutorial
145-
===
146-
147-
```go
148-
func main() {
149-
doc, err := htmlquery.LoadURL("https://www.bing.com/search?q=golang")
150-
if err != nil {
151-
panic(err)
152-
}
153-
// Find all news item.
154-
list, err := htmlquery.QueryAll(doc, "//ol/li")
155-
if err != nil {
156-
panic(err)
157-
}
158-
for i, n := range list {
159-
a := htmlquery.FindOne(n, "//a")
160-
fmt.Printf("%d %s(%s)\n", i, htmlquery.InnerText(a), htmlquery.SelectAttr(a, "href"))
161-
}
162-
}
163-
```
164-
165-
List of supported XPath query packages
166-
===
167-
| Name | Description |
168-
| ------------------------------------------------- | ----------------------------------------- |
169-
| [htmlquery](https://github.com/antchfx/htmlquery) | XPath query package for the HTML document |
170-
| [xmlquery](https://github.com/antchfx/xmlquery) | XPath query package for the XML document |
171-
| [jsonquery](https://github.com/antchfx/jsonquery) | XPath query package for the JSON document |
172-
173161
Questions
174162
===
175163
Please let me know if you have any questions.

0 commit comments

Comments
 (0)