function writeXML(filename, v) % % Transforms a struct or struct array into an XML file % % filename = name of the XML file % v = struct variable containing fields of type char or numeric % % xml.tag.object ='foo' % xml.tag.property(1) = {'foobar1'} % xml.tag.property(2) = {'foobar2'} % xml.tag.childrens(1).name ='Pedro' % xml.tag.childrens(1).age ='12' % xml.tag.childrens(2).name ='Juan' % xml.tag.childrens(2).age ='15' % % writeXML(filename, xml) will generate a .xml file that contains: % % % % foo % % % foobar1 % % % foobar2 % % % % Pedro % % % 12 % % % % % Juan % % % 15 % % % % xml = struct2xml(v); % Open file fid = fopen(filename,'w'); fprintf(fid, xml); % Close file fclose(fid);