B4J Question parsing holidays, MiniHtmlParser

trvip

Member
hi,
I am trying to parse this html code (feiertage) from https://www.ferienwiki.at/feiertage/2025/at, but it fails with error code:
minihtmlparser._gettextfromnode (java line: 301)
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
....

attached is my B4J code, any help is welcome
thx
 

Attachments

  • parseHolidays.zip
    7.9 KB · Views: 15

Erel

B4X founder
Staff member
Licensed User
Longtime User
Step 1:
To debug change code to:
B4X:
For Each td As HtmlNode In tds
            HtmlParser.PrintNode(td)
        Next

Step 2:
B4X:
For i = 0 To trs.Size -1
        Dim tds As List = HtmlParser.FindDirectNodes(trs.Get(i), "td", Null)
        For Each td As HtmlNode In tds
            Dim TextNode As HtmlNode
            Dim a As HtmlNode = HtmlParser.FindNode(td, "a", Null)
            If a.IsInitialized Then
                TextNode = a
            Else
                Dim span As HtmlNode = HtmlParser.FindNode(td, "span", Null)
                If span.IsInitialized Then
                    TextNode = span
                Else
                    TextNode = td
                End If
            End If
            Log(HtmlParser.GetTextFromNode(TextNode, 0))
        Next
    Next
 
Upvote 0
Top