getNodeSet返回零输出

时间:2014-04-13 23:33:04

标签: xml r

我已通过this link访问xml了。我试图将它们转换为R中的数据集。

我使用XML包。 首先,

d <- xmlParse("v1.xml") ## name of the downloaded file, tried link above as well

然后

t <- getNodeSet(d,'//itemId') 

将结果应用于xmlToDataFrame函数。但getNodeSet不返回任何输出。我尝试了不同的xmlPaths和完整路径

("//findCompletedItemsResponse/searchResult/item/itemId") 

但它没有用。

请告诉我是否使用了错误的语法或我的xml文件有任何问题。

1 个答案:

答案 0 :(得分:2)

这是名称空间的问题。使用

getNodeSet(d, "//*[local-name() = 'itemId']")
or
getNodeSet(d, "//x:itemId", namespaces = c(x = "http://www.ebay.com/marketplace/search/v1/services"))