Skip to content

Commit

Permalink
[fix] gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
asciimoo committed Jul 10, 2018
1 parent 10350f9 commit c4dc277
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
26 changes: 12 additions & 14 deletions xmlelement.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func (h *XMLElement) ChildText(xpathQuery string) string {

}


// ChildAttr returns the stripped text content of the first matching
// element's attribute.
func (h *XMLElement) ChildAttr(xpathQuery, attrName string) string {
Expand Down Expand Up @@ -154,19 +153,18 @@ func (h *XMLElement) ChildAttrs(xpathQuery, attrName string) []string {
return res
}

// ChildTexts returns an array of strings corresponding to child elements that match the xpath query.
// ChildTexts returns an array of strings corresponding to child elements that match the xpath query.
// Each item in the array is the stripped text content of the corresponding matching child element.
func (h *XMLElement) ChildTexts(xpathQuery string) []string {
texts := make([]string, 0)
if h.isHTML {
htmlquery.FindEach(h.DOM.(*html.Node), xpathQuery, func(i int, child *html.Node) {
texts = append(texts, strings.TrimSpace(htmlquery.InnerText(child)))
})
} else {
xmlquery.FindEach(h.DOM.(*xmlquery.Node), xpathQuery, func(i int, child *xmlquery.Node) {
texts = append(texts, strings.TrimSpace(child.InnerText()))
})
}
return texts
texts := make([]string, 0)
if h.isHTML {
htmlquery.FindEach(h.DOM.(*html.Node), xpathQuery, func(i int, child *html.Node) {
texts = append(texts, strings.TrimSpace(htmlquery.InnerText(child)))
})
} else {
xmlquery.FindEach(h.DOM.(*xmlquery.Node), xpathQuery, func(i int, child *xmlquery.Node) {
texts = append(texts, strings.TrimSpace(child.InnerText()))
})
}
return texts
}

1 change: 0 additions & 1 deletion xmlelement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package colly_test


import (
"github.com/antchfx/htmlquery"
"github.com/gocolly/colly"
Expand Down

0 comments on commit c4dc277

Please sign in to comment.