| XMLSource {tm} | R Documentation |
Constructs a source for an XML file.
XMLSource(x, parser, reader, encoding = "unknown")
x |
a file name or a connection. |
parser |
a function accepting an XML tree (as delivered by
|
reader |
a function capable of turning XML elements as
returned by |
encoding |
encoding to be assumed for input strings. It is used to mark character strings as known to be in Latin-1 or UTF-8: it is not used to re-encode the input. |
An object of class XMLSource which extends the class
Source representing an XML file.
Ingo Feinerer
Vignette 'Extensions: How to Handle Custom File Formats',
readXML;
Encoding
## An implementation for readGmane is provided as an example in ?readXML
example(readXML)
## Construct a source for a Gmane mailing list RSS feed.
GmaneSource <-
function(x, encoding = "unknown")
XMLSource(x, function(tree)
XML::xmlChildren(XML::xmlRoot(tree))
[names(XML::xmlChildren(XML::xmlRoot(tree))) == "item"],
readGmane, encoding)
## Not run: gs <- GmaneSource("http://rss.gmane.org/gmane.comp.lang.r.general")
elem <- getElem(stepNext(gs))
(gmane <- readGmane(elem, language = "en", id = "id1"))
meta(gmane)
## End(Not run)