我已经通过 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 文件有任何问题。
最佳答案
这是命名空间的问题。使用
getNodeSet(d, "//*[local-name() = 'itemId']")
or
getNodeSet(d, "//x:itemId", namespaces = c(x = "http://www.ebay.com/marketplace/search/v1/services"))
关于xml - getNodeSet 返回零输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23049741/