Home > classes > @timespan > private > fromxml.m

fromxml

PURPOSE ^

FROMXML read from part of an XML tree and create a timespan object.

SYNOPSIS ^

function t = fromxml(xml)

DESCRIPTION ^

 FROMXML read from part of an XML tree and create a timespan object.

 M Hewitson 28-08-07

 $Id: fromxml.html,v 1.6 2008/02/12 12:17:56 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t = fromxml(xml)
0002 
0003 % FROMXML read from part of an XML tree and create a timespan object.
0004 %
0005 % M Hewitson 28-08-07
0006 %
0007 % $Id: fromxml.html,v 1.6 2008/02/12 12:17:56 hewitson Exp $
0008 %
0009 
0010 % disp('---------------- timespan ------------------')
0011 % xml.getNodeName
0012 % disp('---------------- timespan ------------------')
0013 
0014 sch = xml.getChildNodes;
0015 for c=1:sch.getLength
0016   x = sch.item(c-1);
0017   switch char(x.getNodeName)
0018     case 'name'
0019       name = char(x.getTextContent);
0020     case 'start'
0021       xch = x.getChildNodes;
0022       start = time(xch.item(1));
0023     case 'end'
0024       xch = x.getChildNodes;
0025       stop = time(xch.item(1));
0026     case 'timeformat'
0027       xch = x.getChildNodes;
0028       tf = timeformat(xch.item(1));
0029     case 'timezone'
0030       timezone = char(x.getTextContent);
0031     case 'version'
0032       version = char(x.getTextContent);
0033     case 'created'
0034       xch = x.getChildNodes;
0035       created = time(xch.item(1));
0036     otherwise
0037   end
0038 end
0039 
0040 % build time
0041 t = timespan(start, stop, tf);
0042 t = set(t, 'name',     name);
0043 t = set(t, 'timezone', timezone);
0044 t = set(t, 'version',  version);
0045 t = set(t, 'created',  created);
0046 
0047 
0048 % END

Generated on Tue 12-Feb-2008 13:12:45 by m2html © 2003