I want to extract MsgBody from an HTML string using Jsoup of Jsoup.org. In my code below, am I using the correct method to give access to the Java code and decode MyString? Any help greatly appreciated.
Best regards
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim NativeMe As JavaObject
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
If FirstTime Then
NativeMe.InitializeContext
End If
End Sub
Sub ExtractHTML(MyString As String) As String
Try
MyString = NativeMe.RunMethod("decode", Array(MyString))
Catch
Log("LastException: " & LastException)
End Try
Return MyString
End Sub
#if java
import org.jsoup.Jsoup;
import org.jsoup.helper.Validate;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public static String decode(String s){
Document doc = Jsoup.parseBodyFragment(s);
Element body = doc.body();
return body.toString();
}
#end if
Best regards