[R] Extract XMLAtrributeValue

Mohan.Radhakrishnan at cognizant.com Mohan.Radhakrishnan at cognizant.com
Mon Jul 10 09:03:59 CEST 2017


Hi,

I am trying to extract an attribute value which is like this.

(e.g) class="whQuestion"

The 'extract' function prints this. But I am not sure how to get "whQuestion" from that. The type of 'x' in extract
is "character"

[1] "XMLAttributeValue"
       class
"whQuestion"
attr(,"class")

extract <- function(x){
print(x)
}

filteredclasses <-
function(){
classes <- xpathSApply(doc = posts, path = "/*/Posts/Post/@class", extract)
}

Thanks,
Mohan
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.

	[[alternative HTML version deleted]]



More information about the R-help mailing list