XML : Parse xml rows and return string

I am way out of my depth here. I queried the Facebook API to retrieve likes, shares and comments. Then I ended up with this output which is a list of 2 and XML document.

  str (test$mined)   $ :List of 2  ..$ node:<externalptr>   ..$ doc :<externalptr>   ..- attr(*, "class")= chr [1:2] "xml_document" "xml_node"    print (test$mined)  [[402]]  {xml_document}  <html>  [1] <body>\n  <p>[{"share_count":42,"like_count":77,"comment_count":35}]</p>\n</body>    

I would like the output to be in 3 different columns 43, 77, 35 for share, like and comment count respectively.

I experimented a bit the the XML package but I am had not luck. I also read these posts but I was not able to apply it to this particular case.

Apply function to xmlNodeList in R (not whole xml file)

Parse an XML file and return an R character vector

Thanks

No comments:

Post a Comment