简体   繁体   中英

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

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")

You should try "rgexf" library ( http://cran.r-project.org/web/packages/rgexf/ ). There you will find the function "read.gexf". Following your example:

library(rgexf)

mygraph <- read.gexf(" http://gexf.net/data/dynamics_openintervals.gexf ")

This will return a gexf graph object. Try summarizing it

summary(mygraph)

Let me know if it helps

Best wishes

George Author of rgexf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM