Skip to content

How to get matched node names #17

@gaubert

Description

@gaubert

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions