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_stripXmlTags(xml)
function [xmlData] = fc_stripXmlTags(xml)

% The function takes a text string 'xml', which should be the the text
% returned by cocomac urlsearch consisting of a series of tags such as:
% <ID_BrainSite>AM02-V1</ID_BrainSite><SiteType>Area_IsoCtx_2D</SiteType>
% <Hemisphere>?</Hemisphere> etc.
% It returns a cell array 'xmlData' which contains just the data in a
% column of cells, with the xml tags removed

% Divide the xml variable (char vector) into sections using delimiter
% '>', which will chop it into individual <xml tags>, and put into cell
% array splitTags

splitTags = {};
while true
    [splitTags{end+1, 1}, xml] = strtok(xml, '>');
    if isempty(xml) %If there are no more tags...
        break
    end    
end

%Search through splitTags cell array and extract only those with data
%in them (identified by those not starting with a new line character),
%putting them into new cell array xmlData
[noOfTags, dummy] = size(splitTags);
xmlData = {};
for tagCounter = 1:noOfTags

    if double(splitTags{tagCounter}(1)) ~= 10      %If the first character of splitTags isn't a new line char (ASCII code 10) (the char is converted to ASCII value using double() ).
        xmlData{end+1, 1} = splitTags{tagCounter};
    end
end

% strip the closing xml tag from all the strings in xmlData (they begin with a '<')
noOfXmlData = length(xmlData);
for dataCounter = 1 : noOfXmlData
    xmlData{dataCounter} = strtok(xmlData{dataCounter}, '<');
end

return;

Contact us at files@mathworks.com