go-xmlpath / xmlpath

Strict subset of the XPath specification for the Go language.
http://gopkg.in/xmlpath.v2
Other
115 stars 37 forks source link

How to get matched node names #17

Open gaubert opened 8 years ago

gaubert commented 8 years ago

First I am a newbe in golang but I am trying to pass the XML test which is one of the most difficult one for a new language (Who wants to use XML anyway :-) ).

Is there a way to just print the node names that have been matched ? See below in the iterator for each Node I would like to get only the node name by when I stringify it I get the complete node content.

capability_path := xmlpath.MustCompile("//Capability/Request/*")

root, err := xmlpath.Parse(reader)
if err != nil {
        log.Fatal(err)
}
iter := capability_path.Iter(root)
for iter.Next() {
         elem := iter.Node()
         fmt.Println("Found:[", elem.String(),"]")
    }

Thank in advance

gaubert commented 8 years ago

@niemeyer any news on that one ? Many thanks