source: trunk/src/@xmltree/length.m @ 1160

Last change on this file since 1160 was 925, checked in by sommeria, 9 years ago

xmltree updated

File size: 1.1 KB
Line 
1function l = length(tree,r)
2% XMLTREE/LENGTH Length Method
3% FORMAT l = length(tree,r)
4%
5% tree - XMLTree object
6% r    - 'real' if present, returns the real number of nodes in the
7%         tree (deleted nodes aren't populated)
8% l    - length of the XML tree (number of nodes)
9%__________________________________________________________________________
10%
11% Return the number of nodes of an XMLTree object.
12%__________________________________________________________________________
13% Copyright (C) 2002-2011  http://www.artefact.tk/
14
15% Guillaume Flandin
16% $Id: length.m 4460 2011-09-05 14:52:16Z guillaume $
17
18
19%error(nargchk(1,2,nargin));
20
21% Return the full number of nodes once allocated
22l = length(tree.tree);
23
24% Substract the number of deleted nodes to the previous length
25if nargin == 2
26    if strcmp(r,'real')
27        ll = 0;
28        for i=1:l
29            if ~strcmp(tree.tree{i}.type,'deleted')
30                ll = ll + 1;
31            end
32        end
33        l = ll;
34    else
35        error('[XMLTree] Bad input argument.');
36    end
37end
Note: See TracBrowser for help on using the repository browser.