lestrrat-go / libxml2

Interface to libxml2, with DOM interface
MIT License
230 stars 56 forks source link

Get namespaces for node #12

Closed frankstratton closed 8 years ago

frankstratton commented 8 years ago

I see that the Element type has a method to GetNamespaces(), but this method isn't available on a Node type. How can I traverse a document and discover the namespaces on each node?

For example:

root, err := doc.DocumentElement()
fmt.Println(root.NodeType())     // ElementNode
root.GetNamespaces()   // node.GetNamespaces undefined (type types.Node has no field or method GetNamespaces)

I'm at a bit of a loss for converting the root node (or any node) into something that I can call get namespaces on...

frankstratton commented 8 years ago

Nevermind, i figued out you can type assert to

root.(types.Element).GetNamespaces()