comparison m-toolbox/classes/+utils/@xml/getStruct.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
2 function objs = getStruct(node, inhists)
3
4 % Get shape
5 objShape = sscanf(utils.xml.mchar(node.getAttribute('structShape')), '%dx%d')';
6
7 if any(objShape==0)
8
9 objs = struct([]);
10 objs = reshape(objs, objShape);
11
12 else
13
14 objs = [];
15 % Loop over all structure nodes
16 for jj = 1:node.getLength()
17
18 structNode = node.item(jj-1);
19 if structNode.getNodeType == structNode.ELEMENT_NODE
20
21 obj = struct();
22
23 % Loop over all fieldnames
24 for ff = 1:structNode.getLength()
25
26 fieldnameNode = structNode.item(ff-1);
27 if fieldnameNode.getNodeType == fieldnameNode.ELEMENT_NODE
28
29 fname = utils.xml.mchar(fieldnameNode.getNodeName());
30 obj.(fname) = utils.xml.getFromType(fieldnameNode, inhists);
31
32 end
33
34 end
35 objs = [objs obj];
36
37 end
38 end
39
40 objs = reshape(objs, objShape);
41
42 end
43
44 end
45
46