Last change
on this file since 731 was
723,
checked in by sommeria, 11 years ago
|
xmltree and toolbox_calib added to svn
|
File size:
1.0 KB
|
Line | |
---|
1 | function tree = delete(tree,uid) |
---|
2 | % XMLTREE/DELETE Delete (delete a subtree given its UID) |
---|
3 | % |
---|
4 | % tree - XMLTree object |
---|
5 | % uid - array of UID's of subtrees to be deleted |
---|
6 | %_______________________________________________________________________ |
---|
7 | % |
---|
8 | % Delete a subtree given its UID |
---|
9 | % The tree parameter must be in input AND in output |
---|
10 | %_______________________________________________________________________ |
---|
11 | % @(#)delete.m Guillaume Flandin 02/04/08 |
---|
12 | |
---|
13 | error(nargchk(2,2,nargin)); |
---|
14 | |
---|
15 | uid = uid(:); |
---|
16 | for i=1:length(uid) |
---|
17 | if uid(i)==1 |
---|
18 | warning('[XMLTree] Cannot delete root element.'); |
---|
19 | else |
---|
20 | p = tree.tree{uid(i)}.parent; |
---|
21 | tree = sub_delete(tree,uid(i)); |
---|
22 | tree.tree{p}.contents(find(tree.tree{p}.contents==uid(i))) = []; |
---|
23 | end |
---|
24 | end |
---|
25 | |
---|
26 | %======================================================================= |
---|
27 | function tree = sub_delete(tree,uid) |
---|
28 | if isfield(tree.tree{uid},'contents') |
---|
29 | for i=1:length(tree.tree{uid}.contents) |
---|
30 | tree = sub_delete(tree,tree.tree{uid}.contents(i)); |
---|
31 | end |
---|
32 | end |
---|
33 | tree.tree{uid} = struct('type','deleted'); |
---|
Note: See
TracBrowser
for help on using the repository browser.