How to get Matlab to read correct amount of xml nodes

前端 未结 2 541
刺人心
刺人心 2021-01-12 02:50

I\'m reading a simple xml file using matlab\'s xmlread internal function.


    
        

        
2条回答
  •  滥情空心
    2021-01-12 03:28

    I felt that @cholland answer was good, but I didn't like the extra xml work. So here is a solution to strip the whitespace from a copy of the xml file which is the root cause of the unwanted elements.

    fid = fopen('tmpCopy.xml','wt');
    str = regexprep(fileread(filename),'[\n\r]+',' ');
    str = regexprep(str,'>[\s]*<','><');
    fprintf(fid,'%s', str);
    fclose(fid);
    

提交回复
热议问题