On Thu, 16 Jun 2011, Marcos Douglas wrote:

On Thu, Jun 16, 2011 at 10:44 AM,  <michael.vancann...@wisa.be> wrote:


On Thu, 16 Jun 2011, Marcos Douglas wrote:

On Thu, Jun 16, 2011 at 9:32 AM, Jeppe Johansen <jepj...@es.aau.dk> wrote:

Den 16-06-2011 14:09, Marcos Douglas skrev:

I am using the xmlread.ReadXMLFile(doc, stream) function to read a XML.
If I use a file works OK.
If I use a Stream of the same file (I saved the Stream in a file and
compare with de original file... are equal), happen an error:

In 'stream:' (line 1 pos 1): Root element is missing

Do you have an example?

Yes, see:

program t_xml;

{$mode objfpc}{$H+}

uses classes, sysutils, dom, XMLRead;

const
 FILE_NAME = 'test.xml';
var
 Doc: TXMLDocument;
 SL: TStringList;
 m: TMemoryStream;
begin
 ReadXMLFile(Doc, FILE_NAME);   //<<<<<<< OK
 Doc.Free;

 m := TMemoryStream.Create;
 SL := TStringList.Create;
 try
  SL.LoadFromFile(FILE_NAME);
  SL.SaveToStream(m);

Add here
 M.Position:=0;

Correct!
Thanks... but the ReadXMLFile() should do it, don't?

No. For some streams, this will give an exception.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to