Home > atmlab > arts > xml > xmlReadAttributes.m

xmlReadAttributes

PURPOSE ^

Internal function to read attributes of an xml tag.

SYNOPSIS ^

function attrlist = xmlReadAttributes(fid)

DESCRIPTION ^

 Internal function to read attributes of an xml tag.

    Creates a list of attribute name and value pairs.

 FORMAT   attrlist = xmlReadAttributes(fid)

 OUT   attrlist   List of attributes
 IN    fid        File descriptor of input file

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

xmlReadAttributes.m

SOURCE CODE ^

0001 % Internal function to read attributes of an xml tag.
0002 %
0003 %    Creates a list of attribute name and value pairs.
0004 %
0005 % FORMAT   attrlist = xmlReadAttributes(fid)
0006 %
0007 % OUT   attrlist   List of attributes
0008 % IN    fid        File descriptor of input file
0009                                                                                                                                
0010 % 2002-09-25   Created by Oliver Lemke.
0011 
0012 function attrlist = xmlReadAttributes(fid)
0013 
0014 attrlist={};
0015 na = 0;
0016 c = fgets (fid, 1);
0017 while ~feof (fid) && c ~= '>'
0018   attr = [];
0019   while ~feof (fid) && c ~= '=' && c ~= '>'
0020     attr = [attr c];
0021     c = fgets (fid, 1);
0022   end
0023   
0024   attr = strtrim(attr);
0025 
0026   if c == '>', break, end;
0027 
0028   c = fgets (fid, 1);
0029   while ~feof (fid) && c == ' '
0030     c = fgets (fid, 1);
0031   end
0032 
0033   value = '';
0034   c = fgets (fid, 1);
0035   while ~feof (fid) && c ~= '"'
0036     value = [value c];
0037     c = fgets (fid, 1);
0038   end
0039 
0040   na = na + 1;
0041   attrlist{na,1} = attr;
0042   attrlist{na,2} = value;
0043   c = fgets (fid, 1);
0044 end
0045

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005