1
我試圖使用這些twoposts中描述的Xpath代碼來獲取href
的內容。不幸的是,代碼正在返回除了URL之外的實際文本「href」和幾個空格。我怎樣才能避免這種情況?在R XML Xpath中,@ href返回文本「href」
library(XML)
html <- readLines("http://www.msu.edu")
html.parse <- htmlParse(html)
Node <- getNodeSet(html.parse, "//div[@id='MSU-top-utilities']//a/@href")
Node[[1]]
# > Node[[1]]
# href
# "students/index.html"
# attr(,"class")
# [1] "XMLAttributeValue"