view m-toolbox/classes/+utils/@xml/save_sinfo_xml.m @ 1:2014ba5b353a database-connection-manager

Remove old code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Sat, 03 Dec 2011 18:13:55 +0100
parents f0afece42f48
children
line wrap: on
line source

% SAVE_SINFO_XML saves a submission info struct to a simple XML file.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% SAVE_SINFO_XML saves a submission info struct to a simple XML file.
%
%  CALL:   sinfo = utils.helper.save_sinfo_xml(file)
%
% The XML file should have a main node called 'submission_info'. Then all
% sub-nodes supported by the sinfo fields will be read.
%
% For example:
%
% <submission_info>
%   <experiment_title>
%   some nice experiment we can use
%   </experiment_title>
%   <experiment_description>
%   Some nice experiment we did with some crazy results.
%   But sometimes it takes a new line to describe in detail.
%   </experiment_description>
% </submission_info>
%
% Supported fields:
%
% 'experiment_title'
% 'experiment_description'
% 'analysis_description'
% 'quantity'
% 'keywords'
% 'reference_ids'
% 'additional_comments'
% 'additional_authors'
%
% I Diepholz 022-03-10
%
% $Id: save_sinfo_xml.m,v 1.1 2010/04/19 14:31:05 ingo Exp $
%

function save_sinfo_xml(filename, sinfo)
  
  xml = com.mathworks.xml.XMLUtils.createDocument('submission_info');
  parent = xml.getDocumentElement;
  
  fieldNames = fieldnames(sinfo);
  for ii = 1:numel(fieldNames);
    field = fieldNames{ii};
    
    newNode = xml.createElement(field);
    parent.appendChild(newNode);
    
    
    content = xml.createTextNode(sinfo.(field));
    newNode.appendChild(content);    
    
  end

  xmlwrite(filename, xml);
  
end