本文整理匯總了Golang中github.com/ChrisTrenkamp/goxpath/parser/result/pathres.PathRes類的典型用法代碼示例。如果您正苦於以下問題:Golang PathRes類的具體用法?Golang PathRes怎麽用?Golang PathRes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了PathRes類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: findChild
func findChild(x pathres.PathRes, p *pathexpr.PathExpr, ret *[]pathres.PathRes) {
ch := x.GetChildren()
for i := range ch {
if ch[i].EvalPath(p) {
*ret = append(*ret, ch[i])
}
}
}
示例2: Print
//Print prints out the XPath result
func Print(r pathres.PathRes) (string, error) {
ret := bytes.NewBufferString("")
e := xml.NewEncoder(ret)
err := r.Print(e)
if err != nil {
return "", err
}
err = e.Flush()
if err != nil {
return "", err
}
return ret.String(), nil
}
示例3: findAncestor
func findAncestor(x pathres.PathRes, p *pathexpr.PathExpr, ret *[]pathres.PathRes) {
if x.GetParent().EvalPath(p) {
*ret = append(*ret, x.GetParent())
}
if x.GetParent() != x {
findAncestor(x.GetParent(), p, ret)
}
}
示例4: findPrecedingSibling
func findPrecedingSibling(x pathres.PathRes, p *pathexpr.PathExpr, ret *[]pathres.PathRes) {
if x == x.GetParent() {
return
}
par := x.GetParent()
ch := par.GetChildren()
i := len(ch) - 1
for x != ch[i] {
i--
}
i--
for i >= 0 {
findSelf(ch[i], p, ret)
i--
}
}
示例5: findFollowingSibling
func findFollowingSibling(x pathres.PathRes, p *pathexpr.PathExpr, ret *[]pathres.PathRes) {
if x == x.GetParent() {
return
}
par := x.GetParent()
ch := par.GetChildren()
i := 0
for x != ch[i] {
i++
}
i++
for i < len(ch) {
findSelf(ch[i], p, ret)
i++
}
}
示例6: findSelf
func findSelf(x pathres.PathRes, p *pathexpr.PathExpr, ret *[]pathres.PathRes) {
if x.EvalPath(p) {
*ret = append(*ret, x)
}
}
示例7: findParent
func findParent(x pathres.PathRes, p *pathexpr.PathExpr, ret *[]pathres.PathRes) {
if x.GetParent() != x && x.GetParent().EvalPath(p) {
*ret = append(*ret, x.GetParent())
}
}