1

After I parsed a webpage, I can see the xpath like this..

gethelp.df =htmlTreeParse(url, useInternalNodes = T)
gethelp.df
.
.
....
<div class="lia-message-post-date">
        <a class="lia-link-navigation" id="link_14" href="/t5/Facebook/m-p/3947664">
            <span class="DateTime">
        <span class="local-date">?06-05-2013</span>
        <span class="local-time">09:38 AM</span>
</span>
        </a>
    </div>

and I'd like to grab "06-05-2013" part.

So far I tried these and a bunch of others, but it doesn't work. Can anyone point what I'm missing here?

xpathSApply(gethelp.df, "//span[@class='local-time']", xmlGetAttr, "href")
xpathSApply(gethelp.df, "//div[@class='lia-message-post-date']/span", xmlGetAttr, "href")

Thanks!

2
  • The "06-05-2013" is a value rather then an attribute have you tried xmlValue?
    – jdharrison
    Feb 19, 2014 at 0:13
  • Thank you. You were right! It was a value rather than an attribute!! Feb 19, 2014 at 17:51

1 Answer 1

4
xpathSApply(gethelp.df, "//span[@class='local-date']", xmlValue)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.