library(XML)
f = system.file("exampleData", "utf.xml", package = "XML")
doc = xmlTreeParse(f)
Encoding(xmlName(xmlRoot(doc)))
# "unknown"
xmlName(xmlRoot(doc)[[2]])
# [1] "<U+212B>ob"
Encoding(xmlName(xmlRoot(doc)[[2]]))
# [1] "UTF-8"
Sys.setlocale(, "en_US.UTF-8")
xmlName(xmlRoot(doc)[[2]])
#[1] "Åob"
xmlName(xmlRoot(doc)[[3]])
#[1] "garÇon"
Encoding(xmlName(xmlRoot(doc)[[3]]))
#[1] "UTF-8"
Encoding(xmlValue(xmlRoot(doc)[[4]]))
#[1] "unknown"
xmlValue(xmlRoot(doc)[[4]])
#[1] "Simple text"
doc = xmlInternalTreeParse(f)
xmlname(xmlRoot(doc)[[2]])
# [1] "Åob"
u<-"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><t>estimados de índices</t>"
hh<-function(){
tt<-character(0)
text<-function(x) { print(x) ; tt <<- c(tt, x)}
list(text = text,
ft = function(){ tt })
}
z<-xmlEventParse(u, asText=T, handlers=hh())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.