MATLAB: Read in file that has raw binary image data and an XML footer

footerxml

Hello, I need to read in data from a file that contains a large amount of raw binary image data (singles) followed by an XML footer. I can easily read in the image data (if I know the size of the array), but I'm not sure how to then proceed and read in the rest of the file in XML format. The xmlread() function needs a standalone XML file. My thought was to copy (bit by bit) the footer of the file into a temp file that would then be read by xmlread(). But I'm not quite sure how to do that copy just a part of a file into a new file. Any help would be much appreciated.
Justin

Best Answer

You've got the right idea.
Since you know the size of the image, open the mixed image/XML file with fopen, then use fseek to position the reader just after the image. Then use fread to read the tail of the file. Write this text to a temporary file.