Dear All,

I was trying to use savexml() to save the SPM variable to XML file. I end 
up with this error:

??? Error using ==> strrep
Input strings must have one row

Error in ==>>entity at 129
  str = strrep(str,'&','&');

Error in ==>>save_subtree at 113

A bit of debugging shows me that the error is in saving SPM.xY.P. That 
variable is simply a list of all input img files, i.e.


Replacing it with a simple string, e.g. SPM.xY.P=['abc'] resolves the 

The function in question is:
function str = entity(str)
    str = strrep(str,'&','&');
    str = strrep(str,'<','&lt;');
    str = strrep(str,'>','&gt;');
    str = strrep(str,'"','&quot;');
    str = strrep(str,'''','&apos;');

Based on the error message, I deduced that for some reason unknown, it does 
not like my SPM.xY.P which is of length [357 190].

The solution appears to me to be to feed strrep() one row at a time.

That should be simple stuff. Now, you would had thought someone like me 
with 10 years programming experience should be able to fix it quickly. 

Unfortunately, I am not a matlab programmer, I tried to enclose all 
strrep() in a for loop for each row

  for j in 1:mysize(1)
     str(j) = strrep(str(j),'&','&amps;')

but I end up writing rubbish to the str variable.

Can anyone help me out please?

Many thanks in advance and best regards,