Unable to load xml directly from blob

Sunset
Sunset Member Posts: 201
I have a record that has a BLOB containing a xml file. I'm trying to handle the xml without having to write it to a file first, but for some reason I can't load the xml directly from the stream :(

What I'm trying to achieve is the below code, but the resulting xml is blank
CREATE(xmldoc2);
Log.CALCFIELDS("Request XML");
Log."Request XML".CREATEINSTREAM(InS);
xmldoc2.load(InS);
xmldoc2.save('c:\xml\ins.xml');  //Temporary check to see if the xml is valid
The code below works, so I know that the xml file is there. Reading the last characters and truncating, as I noticed that for some reason there are filler chars at the end
Log.CALCFIELDS("Request XML");
Log."Request XML".CREATEINSTREAM(InS);
LogFilename := 'c:\xml\log.xml';
File.CREATE(LogFilename);
File.CREATEOUTSTREAM(OutS);
COPYSTREAM(OutS,InS);
File.READ(LastChar);
WHILE (LastChar[1] = 0) DO BEGIN
  File.SEEK(File.POS - 2);
  File.READ(LastChar);
END;
File.TRUNC;
File.CLOSE;
xmldoc.load(LogFilename);
Realizing that there might be something wrong with the xml going into the blob I've tried checking it there, but it looks ok. The code itself recieves a node, combines it with the processing instruction and saves the result using:
Log."Request XML".CREATEOUTSTREAM(OutS);
OutS.WRITE(xmldoc.xml);
To make sure that ingoing xml was ok I tried saving the result (ends as a proper xml), load that file into a xmldoc and saving that into the blob. The result of the load routine is the same as saving it directly ](*,)

Have tried various ways of generating and saving the record, as well as loading the xml out again; but so far unsuccesful :cry:
I'm slowly running out of things to try, so would love some suggestions [-o< Willing to use some roundabout to reach the goal, but really don't want to involve writing to the disc.
Don't just take my word for it, test it yourself