Skip to content

Commit 496e959

Browse files
authored
Merge pull request #32 from fahimbagar/master
update readme
2 parents f04d0dd + 3b1e740 commit 496e959

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ list := htmlquery.Find(doc, "//a")
6060
#### Find all A elements that have `href` attribute.
6161

6262
```go
63-
list := range htmlquery.Find(doc, "//a[@href]")
63+
list := htmlquery.Find(doc, "//a[@href]")
6464
```
6565

6666
#### Find all A elements with `href` attribute and only return `href` value.
6767

6868
```go
69-
list := range htmlquery.Find(doc, "//a/@href")
69+
list := htmlquery.Find(doc, "//a/@href")
7070
for _ , n := range list{
71-
fmt.Println(htmlquery.InnerText(n)) // output @href value without A element.
71+
fmt.Println(htmlquery.SelectAttr(n, "href")) // output @href value
7272
}
7373
```
7474

@@ -78,6 +78,13 @@ for _ , n := range list{
7878
a := htmlquery.FindOne(doc, "//a[3]")
7979
```
8080

81+
### Find children element (img) under A `href` and print the source
82+
```go
83+
a := htmlquery.FindOne(doc, "//a")
84+
img := htmlquery.FindOne(a, "//img")
85+
fmt.Prinln(htmlquery.SelectAttr(img, "src")) // output @src value
86+
```
87+
8188
#### Evaluate the number of all IMG element.
8289

8390
```go

0 commit comments

Comments
 (0)