本文整理汇总了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())
}
}