Search code examples
xmlrgephi

getNodeSet not returning expected output


> library(XML)
> tdoc <- xmlParse("http://gexf.net/data/dynamics_openintervals.gexf")
> getNodeSet(tdoc,"/gexf/graph/nodes/node")
list()
attr(,"class")
[1] "XMLNodeSet"

I expect it to return a list of two objects, but it just returns an empty list. Here is the example GEXF file I'm working with: http://gexf.net/data/dynamics_openintervals.gexf


Solution

  • Figured this one out. Needed to define the namespace.

    > library(XML)
    > tdoc <- xmlParse("http://gexf.net/data/dynamics_openintervals.gexf")
    > getNodeSet(tdoc,"//gexf:node",
        c(gexf="http://www.gexf.net/1.2draft")