Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@xml/save_sinfo_xml.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % SAVE_SINFO_XML saves a submission info struct to a simple XML file. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % SAVE_SINFO_XML saves a submission info struct to a simple XML file. | |
5 % | |
6 % CALL: sinfo = utils.helper.save_sinfo_xml(file) | |
7 % | |
8 % The XML file should have a main node called 'submission_info'. Then all | |
9 % sub-nodes supported by the sinfo fields will be read. | |
10 % | |
11 % For example: | |
12 % | |
13 % <submission_info> | |
14 % <experiment_title> | |
15 % some nice experiment we can use | |
16 % </experiment_title> | |
17 % <experiment_description> | |
18 % Some nice experiment we did with some crazy results. | |
19 % But sometimes it takes a new line to describe in detail. | |
20 % </experiment_description> | |
21 % </submission_info> | |
22 % | |
23 % Supported fields: | |
24 % | |
25 % 'experiment_title' | |
26 % 'experiment_description' | |
27 % 'analysis_description' | |
28 % 'quantity' | |
29 % 'keywords' | |
30 % 'reference_ids' | |
31 % 'additional_comments' | |
32 % 'additional_authors' | |
33 % | |
34 % I Diepholz 022-03-10 | |
35 % | |
36 % $Id: save_sinfo_xml.m,v 1.1 2010/04/19 14:31:05 ingo Exp $ | |
37 % | |
38 | |
39 function save_sinfo_xml(filename, sinfo) | |
40 | |
41 xml = com.mathworks.xml.XMLUtils.createDocument('submission_info'); | |
42 parent = xml.getDocumentElement; | |
43 | |
44 fieldNames = fieldnames(sinfo); | |
45 for ii = 1:numel(fieldNames); | |
46 field = fieldNames{ii}; | |
47 | |
48 newNode = xml.createElement(field); | |
49 parent.appendChild(newNode); | |
50 | |
51 | |
52 content = xml.createTextNode(sinfo.(field)); | |
53 newNode.appendChild(content); | |
54 | |
55 end | |
56 | |
57 xmlwrite(filename, xml); | |
58 | |
59 end |