Forum > General
Problem with LoadFromStream
wluis:
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
theo:
http://wiki.lazarus.freepascal.org/XML_Tutorial/es
wluis:
ok, thats manual it´s good but no appear anything about LoadFromStream function
Ñuño_Martínez:
--- Quote from: wluis on May 12, 2010, 12:40:10 pm ---ok, thats manual it´s good but no appear anything about LoadFromStream function
--- End quote ---
May be because the method name isn't "LoadFromStream". ;D Actually, this code (from the linked tutorial) loads the data from stream "s":
--- Code: ---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;
--- End code ---
This other (from the same tutorial) shows another way to read from stream:
--- Code: ---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;
--- End code ---
As you see they don't use "LoadFromStream".
wluis:
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 ...
Navigation
[0] Message Index
[#] Next page