xpathSApply(page, "//div[@class = 'raised ']", xmlValue, trim = TRUE))
This works as intended and trims the /n and whitespace from around the nodes I'm trying to get at.
However, if I add the argument 'recursive = FALSE', to only get at the head node:
xpathSApply(page, "//div[@class = 'raised ']", xmlValue, recursive = FALSE, trim = TRUE))
The whitespace and /n are back in the result. If I run the gsub code that makes up the trim function on the answer, it gives me the desired output.
I am using XpathSApply and xmlvalue as below:
xpathSApply(page, "//div[@class = 'raised ']", xmlValue, trim = TRUE))
This works as intended and trims the /n and whitespace from around the nodes I'm trying to get at.
However, if I add the argument 'recursive = FALSE', to only get at the head node: xpathSApply(page, "//div[@class = 'raised ']", xmlValue, recursive = FALSE, trim = TRUE))
The whitespace and /n are back in the result. If I run the gsub code that makes up the trim function on the answer, it gives me the desired output.
Looking at the code (https://github.com/omegahat/XML/blob/4d95a6eff4a7c3ac3dce7c5f9d0dd3862e175cf6/R/xmlNodes.R), it looks like trim is invoked outside the conditional function when recursive is false. This would probably be fixable by adding a trim statement to the two outputs within that conditional function.