Jörgen wrote:
Doc : Jnodes_DocumentClass;
Doc := TJJSoup.JavaClass.parse(URL, 15000) as JNodes_DocumentClass;
JSoup.parse() returns a Document object, not a Document class type. Your
Doc variable needs to be declared as Jnodes_Document instead, and there should
be no cast needed on the parse() result at all.
I tried this line below after modifying the JSoup unit to make connect
return a JNodes_DocumentClass
Why did you make that change? Jsoup.connect() does not return a Document
class type, it returns a Connection object.
JSoup returns classes which only has static functions
No, it doesn't. The Document and Connection classes both have many non-static
methods in them.
but Java2Op thinks it returns instance classes.
Because JSoup really does return object instances, not class types. Clearly
you have read the JSoup documentation carefully enough. Do you think Java2Op
is lying to you?
I think I somehow should convert the JNodes_Document to the Delphi-like
TJNodes_Document class
No, you do not.
The result of my tests of the above code just terminates the app
Not surprising, since you are mangling the code and mismatching what JSoup
actually does.
Try this instead (I can't verify this myself, as my Java2Op is not able to
parse the latest JSoup jar file for some reason):
procedure TNetwork.InitialGet;
var
URL : JURL;
Doc : Jnodes_Document;
begin
URL := TJURL.JavaClass.init(StringToJString(<some URL>));
Doc := TJJSoup.JavaClass.parse(URL, 15000);
// use Doc as needed...
end;
Or:
procedure TNetwork.InitialGet;
var
Doc : Jnodes_Document;
begin
Doc := TJJSoup.JavaClass.connect(StringToJString(<some URL>)).get();
// use Doc as needed...
end;
--
Remy Lebeau (TeamB)
Connect with Us