Reputation: 21
I want to extract data from the table present on web page http://www.moneycontrol.com/financials/afenterprises/profit-lossVI/AFE01#AFE01
I don't need the entire table at once but specific elements
X-path for 1st element is
/html/body/center[2]/div/div[1]/div[8]/div[3]/div[2]/div[2]/div[2]/div[1]/table[2]/tbody/tr[6]/td[2]
i wrote a code
library(rvest)
library(XML)
FJ<-htmlParse("http://www.moneycontrol.com/financials/afenterprises/profit-lossVI/AFE01#AFE01")
data<-xpathSApply(FJ,"/html/body/center[2]/div/div[1]/div[8]/div[3]/div[2]/div[2]/div[2]/div[1]/table[2]/tbody/tr[6]/td[2]")
print(data)
the output comes out to be NULL
Upvotes: 0
Views: 294
Reputation: 11762
It looks like you missed a div
in between and you did basically a wrong "turn"...
xpathSApply(FJ,"/html/body/center[2]/div/div[1]/div[8]/div[3]/div[2]/div[2]/div[2]/div[1]/table[2]/tr[6]/td[2]")
xmlValue(xpathSApply(FJ,"/html/body/center[2]/div/div[1]/div[8]/div[3]/div[2]/div[2]/div[2]/div[1]/table[2]/tr[6]/td[2]")[[1]])
Upvotes: 1