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

fromxml

PURPOSE ^

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

SYNOPSIS ^

function po = fromxml(xml)

DESCRIPTION ^

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

 M Hewitson 28-08-07

 $Id: fromxml.html,v 1.6 2008/02/12 12:18:05 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function po = fromxml(xml)
0002 
0003 % FROMXML read from part of an XML tree and create a pzmodel object.
0004 %
0005 % M Hewitson 28-08-07
0006 %
0007 % $Id: fromxml.html,v 1.6 2008/02/12 12:18:05 hewitson Exp $
0008 %
0009 
0010 
0011 % disp('---------------- pzmodel ------------------')
0012 % xml.getNodeName
0013 % disp('---------------- pzmodel ------------------')
0014 
0015 % default
0016 p.name    = '';
0017 p.poles   = [];
0018 p.zeros   = [];
0019 p.gain    = 0;
0020 p.created = '';
0021 p.version = '';
0022 
0023 sch = xml.getChildNodes;
0024 for c=1:sch.getLength
0025   x = sch.item(c-1);
0026   switch char(x.getNodeName)
0027     case 'name'
0028       p.name = char(x.getTextContent);
0029     case 'gain'
0030       p.gain = str2num(char(x.getTextContent));
0031     case 'poles'
0032       p.poles = [];
0033       xch = x.getChildNodes;
0034       for j=1:xch.getLength
0035         it = xch.item(j-1);
0036         if strcmp(char(it.getNodeName), 'pole')
0037           p.poles = [p.poles pole(it)];
0038         end
0039       end
0040     case 'zeros'
0041       p.zeros = [];
0042       xch = x.getChildNodes;
0043       for j=1:xch.getLength
0044         it = xch.item(j-1);
0045         if strcmp(char(it.getNodeName), 'zero')
0046           p.zeros = [p.zeros zero(it)];
0047         end
0048       end
0049     case 'created'
0050       xch = x.getChildNodes;
0051       p.created = time(xch.item(1));
0052     case 'version'
0053       p.version = char(x.getTextContent);
0054     otherwise
0055   end
0056 end
0057 
0058 % build pzmodel
0059 po = pzmodel(p);
0060 
0061 % END

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