Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@xml/read_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 % READ_SINFO_XML reads a submission info struct from a simple XML file. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % READ_SINFO_XML reads a submission info struct from a simple XML file. | |
5 % | |
6 % CALL: sinfo = utils.helper.read_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 % M Hewitson 08-02-10 | |
35 % | |
36 % $Id: read_sinfo_xml.m,v 1.1 2010/04/19 14:31:05 ingo Exp $ | |
37 % | |
38 | |
39 function pl = read_sinfo_xml(file) | |
40 | |
41 xdoc = xmlread(file); | |
42 | |
43 fields = {'experiment_title', ... | |
44 'experiment_description', ... | |
45 'analysis_description', ... | |
46 'quantity', ... | |
47 'keywords', ... | |
48 'reference_ids', ... | |
49 'additional_comments',... | |
50 'additional_authors'}; | |
51 | |
52 pl = plist(); | |
53 % Look for a submission info node | |
54 for ii=1:xdoc.getLength | |
55 item = xdoc.item(ii-1); | |
56 if strcmp(char(item.getNodeName), 'submission_info') | |
57 % Now get all the fields | |
58 for kk=1:item.getLength | |
59 node = item.item(kk-1); | |
60 name = char(node.getNodeName); | |
61 if any(strcmp(name, fields)) | |
62 pl.append(name, strtrim(char(node.getTextContent))); | |
63 end | |
64 end | |
65 end | |
66 end | |
67 | |
68 end |