[fpc-pascal] In 'stream:' (line 1 pos 1): Root element is missing

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Thu Jun 16 15:44:36 CEST 2011



On Thu, 16 Jun 2011, Marcos Douglas wrote:

> On Thu, Jun 16, 2011 at 9:32 AM, Jeppe Johansen <jepjoh2 at 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;

Michael.
>
>    ReadXMLFile(Doc, m);  //<<<<<<<< ERROR
>  finally
>    SL.Free;
>    m.Free;
>  end;
> end.
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



More information about the fpc-pascal mailing list