Print

Print


Dear All,

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

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

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

Error in ==> xmltree.save>save_subtree at 113
...
[/quote]

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.


str=
/path/to/a
/path/to/b
...

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

The function in question is:
[@xmltree/save.m:127]
function str = entity(str)
    str = strrep(str,'&','&');
    str = strrep(str,'<','&lt;');
    str = strrep(str,'>','&gt;');
    str = strrep(str,'"','&quot;');
    str = strrep(str,'''','&apos;');
[/end]

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. 
Wrong!

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

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

but I end up writing rubbish to the str variable.

Can anyone help me out please?

Many thanks in advance and best regards,
Cinly