Simple classes for identifying an XML document containing R code
These two classes allow the user to identify an XML document or file
as containing R code (amongst other content). Objects of either of these
classes can then be passed to source
to read the
code into R and also used in link{xmlSource}
to read just parts of it.
XMLCodeFile
represents the file by its name;
XMLCodeDoc
parses the contents of the file when the R object is created.
Therefore, an XMLCodeDoc
is a snapshot of the contents at a moment in time
while an XMLCodeFile
object re-reads the file each time and so reflects
any "asynchronous" changes.
One can create these objects using coercion methods, e.g
as("file/name", "XMLCodeFile")
or as("file/name", "XMLCodeDoc")
.
One can also use xmlCodeFile
.
.Data
:Object of class "character"
signature(x = "XMLCodeFile", i = "ANY", j = "ANY")
:
this method allows one to retrieve/access an individual R code element
in the XML document. This is typically done by specifying the value of the XML element's
"id" attribute.
signature(from = "XMLCodeFile", to = "XMLCodeDoc")
:
parse the XML document from the "file" and treat the result as a
XMLCodeDoc
object.
signature(file = "XMLCodeFile")
: read and evaluate all the
R code in the XML document. For more control, use xmlSource
.
Duncan Temple Lang
src = system.file("exampleData", "Rsource.xml", package = "XML") # mark the string as an XML file containing R code k = xmlCodeFile(src) # read and parse the code, but don't evaluate it. code = xmlSource(k, eval = FALSE) # read and evaluate the code in a special environment. e = new.env() ans = xmlSource(k, envir = e) ls(e)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.