readKeyValueDB: Read an XML property-list (plist) style document

readKeyValueDBR Documentation

Read an XML property-list (plist) style document

Description

This function and its methods reads a property-list/plist XML document used on some operating systems and other places to serialize data. These used to be used for property lists on OS X and can represent arbitrary data relatively conveniently. The format has a root node named plist and then typically an object such as a dictionary or array. A dictionary is a series of name-value or key-value pairs. An array is a sequence of elements. While the function is named readKeyValueDB, it can now read more generally, i.e., plist files whose primary element is not a dict object.

Usage

readKeyValueDB(doc, ...)

Arguments

doc

the object containing the data. This can be the name of a file, a parsed XML document or an XML node.

...

additional parameters for the methods. One can pass dropComments as a logical value to control whether comment nodes are processed or ignored (TRUE). Also, one can specify a value of TRUE or FALSE for a simplify argument. This controls whether we attempt to simplify the result of array nodes to a vector (using simplify2array) or not.

Value

An R object representing the data read from the XML content. This is typically a named list or vector where the names are the keys and the values are collected into an R "container".

Author(s)

Duncan Temple Lang

References

Property lists.

See Also

readSolrDoc, xmlToList, xmlToDataFrame, xmlParse

Examples

  b = readKeyValueDB(system.file("examples/BoxEdit.launch.plist", package = "XML"))

  # an array not a dict as the top node in the plist.
  f = system.file("examples/array.plist", package = "XML")
  a = readKeyValueDB(f)
  a2 = readKeyValueDB(f, simplify = FALSE)

  readKeyValueDB("<plist><string>XYZ</string></plist>")

  readKeyValueDB("<plist><array><string>XYZ</string><real>3.1415</real></array></plist>")

  readKeyValueDB("<plist><array><string>XYZ</string><real>3.1415</real></array></plist>", simplify = FALSE)

  if(file.exists("/usr/share/hiutil/Stopwords.plist")) 
     o = readKeyValueDB("/usr/share/hiutil/Stopwords.plist")

  if(file.exists("/usr/share/java/Tools/Applet Launcher.app/Contents/Info.plist"))
     javaInfo = readKeyValueDB('/usr/share/java/Tools/Applet Launcher.app/Contents/Info.plist')

omegahat/XML documentation built on Jan. 17, 2024, 6:47 p.m.