-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathroot.m
36 lines (31 loc) · 1.18 KB
/
root.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function uid = root(tree)
% XMLTREE/ROOT Root Method
% FORMAT uid = root(tree)
%
% tree - XMLTree object
% uid - UID of the root element of tree
%_______________________________________________________________________
%
% Return the uid of the root element of the tree.
%_______________________________________________________________________
% Copyright (C) 2002-2008 http://www.artefact.tk/
% Guillaume Flandin <guillaume@artefact.tk>
% $Id: root.m 1460 2008-04-21 17:43:18Z guillaume $
% Actually root is necessarily the element whos UID is 1, by
% construction. However, xml_parser should return a tree with a ROOT
% element with as many children as needed but only ONE *element* child
% who would be the real root (and this method should return the UID of
% this element).
uid = 1;
% Update:
% xml_parser has been modified (not as explained above) to handle the
% case when several nodes are at the top level of the XML.
% Example: <!-- beginning --><root>blah blah</root><!-- end -->
% Now root is the first element node of the tree.
% Look for the first element in the XML Tree
for i=1:length(tree)
if strcmp(get(tree,i,'type'),'element')
uid = i;
break
end
end