getElement {prada}R Documentation

Functions to extract atomic data types (numeric, character) and vectors from an XML tree

Description

Functions to extract atomic data types (numeric, character) and vectors from an XML tree that was generated by Urban Liebel's Labview image analysis program

Usage

  getElement(node, name, type="numeric")
  getVector(node, name, elementnames, elementtypes)

Arguments

node XMLNode. A node of an XML tree
name character. The expected name of the node. Maybe NULL for getVector, is mandatory for getElement. If xmlName(node) is not the same as name, an error message is generated.
type Character. Should be either numeric or character.
elementnames list. The list may be nested, thus describing a tree. This tree must correspond to the XML subtree starting at node. The leaves of elementnames should be of class character and contain the names of the leave nodes of the XML subtree.
elementtypes list. Same form as elementnames. The leaves of elementtypes should be of class character and contain the types of the leave nodes of the XML subtree.

Details

getVector descends into the XML subtree starting at node recursively. The atomic elements of the nested lists elementnames and elementtypes are used as the arguments name and type of the call to getElement for the corresponding leave nodes.

Value

A flat list (the result of unlist) with the values from the XML subtree and names unlist(elementnames).

Author(s)

Wolfgang Huber http://www.dkfz.de/abt0840/whuber

See Also

Examples

 
  exfile = file.path(.path.package("prada"), "extdata", "dorit13_2c-1-2--13-Ytrail=3143937171.xml")
  z      = xmlTreeParse(exfile)
  r      = xmlRoot(z)[[2]]
  getElement(r[[3]], name="current clone", type="character")

  thenames = list("Area (pixels)", "Perimeter", "Projection x", "Projection y",
      "Longest Segment Length",
      list("x1Left", "y1Top", "x2Right", "y2Bottom"),
      "Number of Holes", "Hole's Area (pixels)", "Dapi mean",
      "Brdu mean", "transfection mean")
  thetypes = c(rep("numeric", 5), list(rep("numeric", 4)), rep("numeric", 5))

  getVector(r[[4]][[6]], name=NULL, elementnames=thenames, elementtypes=thetypes)
  getElement(r[[4]][[6]][[3]], "Area (pixels)")

[Package Contents]