% ****************************************************************************** % Matlab function to load series from a Blue Leaf Software Dagra document. % strFilename is the filename of the document % returns: a structure containing one field for each % series loaded. The name of each field is the unique % name from the document file. Each series field contains % an x field and a y field containing the data loaded. % Copyright 2008 Blue Leaf Software. http://www.BlueLeafSoftware.com % You may created derived works from this file provided that this copyright % message is retained in any derived works and that you mark derived works as % such. Blue Leaf Software is not responsible for any alterations made to this % code and does not guarantee that the file format for Dagra documents will not % change in future releases. % ****************************************************************************** function data = LoadDagra(strFilename) % Read in the content of the xml file. oXmlFile = xmlread(strFilename); % Extract the information associated with each series. oSeries = oXmlFile.getElementsByTagName('reduced'); nSeries = oSeries.getLength; % For each series found, add to the data structure. for i = 1:nSeries oCurrent = oSeries.item(i - 1); % Get the unique series name, x values and y-values strName = oCurrent.getAttribute('unique-name').toCharArray'; oX = oCurrent.getElementsByTagName('x'); strX = oX.item(0).getTextContent.toCharArray; oY = oCurrent.getElementsByTagName('y'); strY = oY.item(0).getTextContent.toCharArray; % Parse the data and save in structure. Unique name is the % field name. data.(strName).x = sscanf(strX, '%g'); data.(strName).y = sscanf(strY, '%g'); end