示例#1
0
func subNodes(xn *xmlx.Node, name string) (sn []*xmlx.Node) {
	if sn = xn.SelectNodes(ns, name); len(sn) == 0 {
		if sn = xn.SelectNodes("", name); len(sn) == 0 {
			sn = xn.SelectNodes("*", name)
		}
	}
	return
}
示例#2
0
func xcns(xn *xmlx.Node, names ...string) (cns []*xmlx.Node) {
	if len(names) == 1 {
		if cns = xn.SelectNodes(xmlns, names[0]); len(cns) == 0 {
			if cns = xn.SelectNodes("", names[0]); len(cns) == 0 {
				cns = xn.SelectNodes("*", names[0])
			}
		}
	} else {
		var scns []*xmlx.Node
		for _, n := range names {
			if scns = xcns(xn, n); len(scns) > 0 {
				cns = append(cns, scns...)
			}
		}
	}
	if len(cns) > 0 && cns[0].Parent == xn.Parent {
		cns = cns[1:]
	}
	return
}