source: trunk/src/@xmltree/root.m @ 1099

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

xmltree updated

File size: 1.2 KB
RevLine 
[925]1function uid = root(tree)
2% XMLTREE/ROOT Root Method
3% FORMAT uid = root(tree)
4%
5% tree   - XMLTree object
6% uid    - UID of the root element of tree
7%__________________________________________________________________________
8%
9% Return the uid of the root element of the tree.
10%__________________________________________________________________________
11% Copyright (C) 2002-2008  http://www.artefact.tk/
12
13% Guillaume Flandin
14% $Id: root.m 4460 2011-09-05 14:52:16Z guillaume $
15
16% Actually root is necessarily the element whos UID is 1, by
17% construction. However, xml_parser should return a tree with a ROOT
18% element with as many children as needed but only ONE *element* child
19% who would be the real root (and this method should return the UID of
20% this element).
21
22uid = 1;
23
24% Update:
25% xml_parser has been modified (not as explained above) to handle the
26% case when several nodes are at the top level of the XML.
27% Example: <!-- beginning --><root>blah blah</root><!-- end -->
28% Now root is the first element node of the tree.
29
30% Look for the first element in the XML Tree
31for i=1:length(tree)
32    if strcmp(get(tree,i,'type'),'element')
33        uid = i;
34        break
35    end
36end
Note: See TracBrowser for help on using the repository browser.