XMLCodeFile-class

0th

Percentile

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.

Keywords
classes
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.

See Also

xmlSource

Aliases
  • XMLCodeFile-class
  • XMLCodeDoc-class
  • xmlCodeFile
  • [[,XMLCodeFile-method
  • [[,XMLCodeFile,ANY-method
  • coerce,XMLCodeFile,XMLCodeDoc-method
  • coerce,character,XMLCodeDoc-method
  • coerce,character,XMLCodeFile-method
  • source,XMLCodeFile-method
Examples
# NOT RUN {
 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)
# }
Documentation reproduced from package XML, version 3.98-1.19, License: BSD_2_clause + file LICENSE

Community examples

Looks like there are no examples yet.