Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import "fmt"
import xmlx "github.com/jteeuwen/go-pkg-xmlx"
var demo = `
<document>
<collection>
<category>One</category>
<category>Two</category>
<item>
<category>Three</category>
</item>
</collection>
</document>
`
func main() {
doc := xmlx.New()
if err := doc.LoadString(demo, nil); err != nil {
panic(err)
}
coll := doc.SelectNode("", "collection")
// I would expect this to print 2. It prints 3
fmt.Printf("Total: %d\n", len(coll.SelectNodes("", "category")))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment