本文整理匯總了Golang中github.com/ChrisTrenkamp/goxpath/tree.Node.GetNodeType方法的典型用法代碼示例。如果您正苦於以下問題:Golang Node.GetNodeType方法的具體用法?Golang Node.GetNodeType怎麽用?Golang Node.GetNodeType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ChrisTrenkamp/goxpath/tree.Node
的用法示例。
在下文中一共展示了Node.GetNodeType方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: findAncestor
func findAncestor(x tree.Node, p *pathexpr.PathExpr, ret *[]tree.Node) {
if x.GetNodeType() == tree.NtRoot {
return
}
addNode(x.GetParent(), p, ret)
findAncestor(x.GetParent(), p, ret)
}
示例2: findPrecedingSibling
func findPrecedingSibling(x tree.Node, p *pathexpr.PathExpr, ret *[]tree.Node) {
if x.GetNodeType() == tree.NtRoot {
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--
}
}
示例3: findFollowingSibling
func findFollowingSibling(x tree.Node, p *pathexpr.PathExpr, ret *[]tree.Node) {
if x.GetNodeType() == tree.NtRoot {
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++
}
}
示例4: encTok
func encTok(n tree.Node, e *xml.Encoder) error {
switch n.GetNodeType() {
case tree.NtAttr:
return encAttr(n.GetToken().(xml.Attr), e)
case tree.NtElem:
return encEle(n.(tree.Elem), e)
case tree.NtNs:
return encNS(n.GetToken().(xml.Attr), e)
case tree.NtRoot:
for _, i := range n.(tree.Elem).GetChildren() {
err := encTok(i, e)
if err != nil {
return err
}
}
return nil
}
//case tree.NtChd, tree.NtComm, tree.NtPi:
return e.EncodeToken(n.GetToken())
}
示例5: addNode
func addNode(x tree.Node, p *pathexpr.PathExpr, ret *[]tree.Node) {
add := false
tok := x.GetToken()
switch x.GetNodeType() {
case tree.NtAttr:
add = evalAttr(p, tok.(xml.Attr))
case tree.NtChd:
add = evalChd(p)
case tree.NtComm:
add = evalComm(p)
case tree.NtElem, tree.NtRoot:
add = evalEle(p, tok.(xml.StartElement))
case tree.NtNs:
add = evalNS(p, tok.(xml.Attr))
case tree.NtPi:
add = evalPI(p)
}
if add {
*ret = append(*ret, x)
}
}
示例6: findParent
func findParent(x tree.Node, p *pathexpr.PathExpr, ret *[]tree.Node) {
if x.GetNodeType() != tree.NtRoot {
addNode(x.GetParent(), p, ret)
}
}