XMLCodeFile-class: Simple classes for identifying an XML document containing R...

Description Objects from the Class Slots Extends Methods Author(s) See Also Examples

Description

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.

Objects from the Class

One can create these objects using coercion methods, e.g as("file/name", "XMLCodeFile") or as("file/name", "XMLCodeDoc"). One can also use xmlCodeFile.

Slots

.Data:

Object of class "character"

Extends

Class "character", from data part. Class "vector", by class "character", distance 2.

Methods

[[

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.

coerce

signature(from = "XMLCodeFile", to = "XMLCodeDoc"): parse the XML document from the "file" and treat the result as a XMLCodeDoc object.

source

signature(file = "XMLCodeFile"): read and evaluate all the R code in the XML document. For more control, use xmlSource.

Author(s)

Duncan Temple Lang

See Also

xmlSource

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 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)


Search within the XML package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.