get.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. function value = get(tree,uid,parameter)
  2. % XMLTREE/GET Get Method (get object properties)
  3. % FORMAT value = get(tree,uid,parameter)
  4. %
  5. % tree - XMLTree object
  6. % uid - array of uid's
  7. % parameter - property name
  8. % value - property value
  9. %__________________________________________________________________________
  10. %
  11. % Get object properties of a tree given their UIDs.
  12. %__________________________________________________________________________
  13. % Copyright (C) 2002-2011 http://www.artefact.tk/
  14. % Guillaume Flandin
  15. % $Id: get.m 4460 2011-09-05 14:52:16Z guillaume $
  16. %error(nargchk(2,3,nargin));
  17. value = cell(size(uid));
  18. uid = uid(:);
  19. if nargin==2
  20. for i=1:length(uid)
  21. if uid(i)<1 || uid(i)>length(tree.tree)
  22. error('[XMLTree] Invalid UID.');
  23. end
  24. % According to the type of the node, return only some parameters
  25. % Need changes...
  26. value{i} = tree.tree{uid(i)};
  27. end
  28. else
  29. for i=1:length(uid)
  30. try
  31. value{i} = subsref(tree.tree{uid(i)}, struct('type','.','subs',parameter));
  32. catch
  33. error(sprintf('[XMLTree] Parameter %s not found.',parameter));
  34. end
  35. end
  36. end
  37. if length(value)==1
  38. value = value{1};
  39. end