Skip to content

readstruct

io · scripts/io/readstruct.m

READSTRUCT  Read a structure from an XML or JSON file (MATLAB compatible).

  S = READSTRUCT (FILENAME) reads FILENAME; the format follows the file
  extension (.xml or .json, anything else is read as JSON).
  S = READSTRUCT (FILENAME, 'FileType', TYPE, 'AttributeSuffix', SUF)
  selects the format explicitly and sets the suffix appended to the names
  of XML attributes (default 'Attribute').

  JSON is parsed with the built-in JSONDECODE; XML is parsed with the Java
  DOM bundled with the product (no external interpreter is involved).
  Repeated XML elements become vectors, struct arrays or cell arrays.