I am getting this error while trying to use MiniHtmlParser. I am new to this library and its use so there is probably something that I am doing wrong.
Error occurred on line: 276 (MiniHtmlParser)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object anywheresoftware.b4a.objects.collections.List.Get(int)' on a null object reference
at com.kangaroosoftware.historicalmarkers.minihtmlparser._gettextfromnode(minihtmlparser.java:203)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:7617)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
The HTML code that I am interested in parsing is so.
...
<script>
var plainText = document.getElementById('inscription1').innerText;
document.getElementById('inscription1').innerHTML = plainText;
</script>
<span id=speakbutton1 style='cursor
ointer;' onclick="speak(document.getElementById('inscription1').innerHTML,1,'en')"><img src=SpeakIcon.png title='Click to hear the inscription.'></span> The Morgan Raiders arrived in Versailles at 1 p.m., Sunday, July 12, 1863, and proceeded to rob the county treasury and to obtain fresh horses. The Raiders also captured and paroled 300 local men, who had assembled in hopes of defending Versailles. One of Morgan's men robbed the local Masonic Lodge of its jewelry. Morgan, a staunch Mason, ordered the items returned and the thief reprimanded.<br><br>
The Raiders left at 4 p.m. in several directions with orders to converge at present-day St. Paul. Union General Edward H. Hobson and the pursuing Union Cavalry arrived Sunday evening, only four hours behind Morgan. That night the Union forces camped west of Versailles. (Note the Historical Markers on the courthouse lawn.)<br> <br><span class=sectionhead> ...
My code is thus
strHTML = File.ReadString(File.DirInternal, "TheHTML.txt")
Dim root As HtmlNode = parser.Parse(strHTML)
Dim span As HtmlNode = parser.FindNode(root, "span", parser.CreateHtmlAttribute("id", "speakbutton1"))
Log(parser.GetTextFromNode(span, 0))