thtmldocument (DOM_HTML), get dom string ? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- BubikolRamios · 2018-02-19 08:10 what goes wrong here ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   doc: thtmldocument;  domNodeList: tdomnodelist;  domNode:TDOMNode;begin   //this works, tested, gets doc from some HTML page.   doc := GetDoc(FileUtil.CreateAbsolutePath(SynEdit1.Lines[i],siteRoorUrl));   //Project xxxraised exception class 'External: SIGFPE'.   //At address 1002569A3   domNode := TDOMNode(doc.GetElementsByTagName('body')[0]); ---------------------------------------------------------------------- molly · 2018-02-19 08:14 Quote from: BubikolRamios on February 19, 2018, 09:10:04 amwhat goes wrong here ? Code: [Select]GetDoc(FileUtil.CreateAbsolutePath(SynEdit1.Lines,siteRo orUrl)); What does GetDoc actually do ? download a html file from the interwebs for you ?  i don't think so ---------------------------------------------------------------------- BubikolRamios · 2018-02-19 08:16 not purified: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TForm1.GetDoc (url: String): thtmldocument;var  HTTPGetResult: Boolean;  HTTPSender: THTTPSend;  //outString: string;   doc: thtmldocument;  //els: tdomnodelist;   //i: integer = 0; begin    //downloading html  //http://wiki.lazarus.freepascal.org/Synapse   //URL := Edit1.Text;  //Result := False;  HTTPSender := THTTPSend.Create;  try    HTTPGetResult := HTTPSender.HTTPMethod('GET', url);    siteRoorUrl := HTTPSender.TargetHost;     if (HTTPSender.ResultCode >= 100) and (HTTPSender.ResultCode<=299) then begin      //SetString(outString, HTTPSender.Document.Memory, HTTPSender.Document.Size);      //showmessage(outString);      //Result := True;       //tstringstream to doc      readhtmlfile(doc,HTTPSender.Document);    end;  finally  HTTPSender.Free;  end;   result :=  doc;end; ---------------------------------------------------------------------- molly · 2018-02-19 08:31 Cool, guessing games.  next on the list: is your DOC variable initialized somewhere ? better check to make sure before parsing. Code: [Select]doc := GetDoc(FileUtil.CreateAbsolutePath(SynEdit1.Lines[i],siteRoorUrl)); if assigned(doc) then begin   // parse the document end ---------------------------------------------------------------------- BubikolRamios · 2018-02-19 08:47 As I told before, it is assigned. Nevertheless putted your check in. Quote//this works, tested, gets doc from some HTML page problem is in last line from OP. Checked page html, 'body' element is there. ---------------------------------------------------------------------- molly · 2018-02-19 08:53 Before getting too frustrated, make sure you do some defensive programming when parsing html files otherwise you'll give up in the end. Code: [Select]TDOMNode(doc.GetElementsByTagName('body')[0]); is not considered defensive, rather you assume that GetElementsByTagName will always result in a valid returned NodeList and that it contains at least one entry. Mind you, i can not see/mimic your retrieved html contents. Hence the guessing ---------------------------------------------------------------------- BubikolRamios · 2018-02-19 09:10 I get frustrated every time, doing something from  scratch with lazarus. Debugging is terrible. I do remember delphi 3.0 or something like that, it was much better. Doing things mostly with java where debugging shows things as it should. if filling so, you can test actual page: Quotehttp://www.pomurske-lekarne.si/javna-narocila/ Defensive programming comes last, always (-: I want some results first (-: ---------------------------------------------------------------------- molly · 2018-02-19 10:30 Debugging structures can be a bit problematic sometimes with lazarus. I rather skip it. I do most my work with fpc. It can't hurt to at least write out some lines sometimes  I think your problem might be that when the stream is read with html data that its position is set to the end of the stream. Therefor parsing it into a htmldocument delivers nothing at all. I do not have experience with synapse though, so am assuming that HTTPSender.Document is a stream and faces the same issue ?