No BSD License  

Highlights from
CoCoMac

image thumbnail
from CoCoMac by James Allen
Download CoCoMac.org cortical connectivity data, model it as a network, and simulate epileptic sprea

fc_validate_xml(xmlWithHeader, brainArea)
function [valid] = fc_validate_xml(xmlWithHeader, brainArea)

% Function to validate an xml string returned by urlread function
% (xmlWithHeader). The function tests for absence of data, presence of an
% xml declaration (<?xml...>), error reports, and a <results> tag. Failure
% to validate returns a 0.
% Author: James Allen   Date: July 2006

valid = 1;

if isempty(xmlWithHeader) == 1
    errordlg(['Error with cocomac XML: ' brainArea ' - xml var returned was empty!'])
    valid = 0;
    return;
end

if (xmlWithHeader(1:5) ~= '<?xml')
    errordlg(['Error with cocomac XML: ' brainArea ' - does not begin with <?xml'])
    valid = 0;
    return;
end

%Check for a typical error from cocomac database which is an html page beginning
%with <font
if (xmlWithHeader(2:6) == '<font')
    errordlg(['Error with cocomac XML: ' brainArea ' - cocmac database error returned'])
    valid = 0;
    return;
end

%Search for an <error> tag in cocomac XML - if there is one, cocoError
%is not empty - print the error message
cocoError = strfind(xmlWithHeader, '<Error>');
if (isempty(cocoError) == 0)
    errordlg(['Error message from cocomac when processing ' brainArea ' - ' xmlWithHeader(cocoError: cocoError+60)])
    valid = 0;
    return;
end

if (length(xmlWithHeader) < 900)
    errordlg(['Warning - cocomac XML for ' brainArea ' has fewer than 900 characters!'])
    valid = 0;
    return;
end

if (strfind(xmlWithHeader, '<Results>') == [])
    errordlg(['Error with cocomac XML: ' brainArea ' - no <Results>!'])
    valid = 0;
    return;
end

return

Contact us at files@mathworks.com