Recent

Author Topic: Problem with LoadFromStream  (Read 13198 times)

wluis

  • New Member
  • *
  • Posts: 16
Problem with LoadFromStream
« on: May 12, 2010, 05:16:22 am »
hello my name is walter and I have a problem:

Create a bearing component for delphi 7 to Lazarus 0.9.29 which uses DOM to read xml files, but when I go to apply LoadFromStream function gives me an error of method is not identified, does not assume that this function is inside the DOM unit ?

httpStream: TStream
.....
  begin
    httpStream.Position := 0;
    FdmWMSClient.xmlDoc.LoadFromStream(httpStream);////////////here is the error: ...cmpwmsclient.pas(182,25) Error: identifier idents no member "LoadFromStream"....
....
  finally
  httpStream.Free;
  end;
end;

what can i do please somebody helpme and greeting from Cuba, your home here is in my house.
sorry for my english
« Last Edit: May 12, 2010, 05:36:55 am by wluis »

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1933

wluis

  • New Member
  • *
  • Posts: 16
Re: Problem with LoadFromStream
« Reply #2 on: May 12, 2010, 12:40:10 pm »
ok, thats manual it´s good but no appear anything about LoadFromStream function

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1222
    • Burdjia
Re: Problem with LoadFromStream
« Reply #3 on: May 12, 2010, 12:58:26 pm »
ok, thats manual it´s good but no appear anything about LoadFromStream function
May be because the method name isn't "LoadFromStream". ;D Actually, this code (from the linked tutorial) loads the data from stream "s":

Code: [Select]
Var
  S : TStringStream;
  XML : TXMLDocument;
 
begin
  S:= TStringStream.Create(MyXMLString);
  Try
    S.Position:=0;
    XML:=Nil;
    ReadXMLFile(XML,S); // Loads complete XML document FROM STREAM "S".
    // Alternatively:
    ReadXMLFragment(AParentNode,S); // Read only XML fragment.
  Finally
    S.Free;
  end;
end;

This other (from the same tutorial) shows another way to read from stream:

Code: [Select]
procedure TMyObject.DOMFromStream(AStream: TStream);
var
  Parser: TDOMParser;
  Src: TXMLInputSource;
  TheDoc: TXMLDocument;
begin
  // create a parser object
  Parser := TDOMParser.Create;
  // and the input source
  Src := TXMLInputSource.Create(AStream);
  // we want validation
  Parser.Options.Validate := True;
  // assign a error handler which will receive notifications
  Parser.OnError := @ErrorHandler;
  // now do the job
  Parser.Parse(Src, TheDoc);
  // ...and cleanup
  Src.Free;
  Parser.Free;
end;
 
procedure TMyObject.ErrorHandler(E: EXMLReadError);
begin
  if E.Severity = esError then  // we are interested in validation errors only
    writeln(E.Message);
end;

As you see they don't use "LoadFromStream".
« Last Edit: May 12, 2010, 01:02:57 pm by Ñuño_Martínez »
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

wluis

  • New Member
  • *
  • Posts: 16
Re: Problem with LoadFromStream
« Reply #4 on: May 12, 2010, 01:52:52 pm »
definitely not using the "LoadFromStream" but, is that´s  your put a streaming method??
i try using what you gave me but it does not work, something I do wrong ...

wluis

  • New Member
  • *
  • Posts: 16
Re: Problem with LoadFromStream
« Reply #5 on: May 12, 2010, 03:15:42 pm »
ok, thats manual it´s good but no appear anything about LoadFromStream function
May be because the method name isn't "LoadFromStream". ;D Actually, this code (from the linked tutorial) loads the data from stream "s":

Code: [Select]
Var
  S : TStringStream;
  XML : TXMLDocument;
 
begin
  S:= TStringStream.Create(MyXMLString);
  Try
    S.Position:=0;
    XML:=Nil;
    ReadXMLFile(XML,S); // Loads complete XML document FROM STREAM "S".
    // Alternatively:
    ReadXMLFragment(AParentNode,S); // Read only XML fragment.
  Finally
    S.Free;
  end;
end;

This other (from the same tutorial) shows another way to read from stream:

Code: [Select]
procedure TMyObject.DOMFromStream(AStream: TStream);
var
  Parser: TDOMParser;
  Src: TXMLInputSource;
  TheDoc: TXMLDocument;
begin
  // create a parser object
  Parser := TDOMParser.Create;
  // and the input source
  Src := TXMLInputSource.Create(AStream);
  // we want validation
  Parser.Options.Validate := True;
  // assign a error handler which will receive notifications
  Parser.OnError := @ErrorHandler;
  // now do the job
  Parser.Parse(Src, TheDoc);
  // ...and cleanup
  Src.Free;
  Parser.Free;
end;
 
procedure TMyObject.ErrorHandler(E: EXMLReadError);
begin
  if E.Severity = esError then  // we are interested in validation errors only
    writeln(E.Message);
end;

As you see they don't use "LoadFromStream".



see
I send a project done in Delphi 7 to Lazarus 0.9.29 is a component that when I use one component registered, gives me an error like this:

Error creating component xxx
Failed to initialize component: Streaming method not available.

I thought I needed a method of stream as loadfromstream Delphi 7 and I used the last you gave me and compiled fine, but when I use the object once again gives me the error, I'm desperate please help

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1222
    • Burdjia
Re: Problem with LoadFromStream
« Reply #6 on: May 12, 2010, 10:37:29 pm »
I am very sorry but I don't understand what you said. Are you using an automatic translator, such as Babelfish or Google's one? May be you can put here your question in English and in your own language. There are people here that speaks a lot of languages (English, Polish, Spanish, Portuguese, French, Deutsch, German, Arabian, Chinese, Japanese...) so may be somebody do understand it and help you.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

 

TinyPortal © 2005-2018