How to Parse HTML from Description Field

Hi all

The client maintains some version data in a table, stored in the Tat Plan-Folder-Description Field.

Parsing HTML Table Fields is no problem, but in HP workflow, its not working for some reason.

What am I doing Wrong? In the code below, the problem is thrown in the creation (or utilisation) of the

    Set oDom = CreateObject("htmlFile")
    oDom.body.innerHtml = HTMLToParse

sequence...

Thanks

Sub TestFolder_MoveTo
  'On Error Resume Next
  Debugger.OutputDebugString TestFolder_Fields.Field("AL_MEMO").Value
  ExtractVersionFromHTML (TestFolder_Fields.Field("AL_MEMO").Value)
  'On Error GoTo 0
End Sub

Sub ExtractVersionFromHTML(HTMLToParse)

    Set oDom = CreateObject("htmlFile")
    x = 0

    'THis is where the error is thrown
    oDom.body.innerHtml = HTMLToParse

    ReDim data(oDom.getelementsbytagname("table")(0).Rows.Length, 0)
    For Each oRow In oDom.getelementsbytagname("table")(0).Rows
        data(x, 0) = oRow.Cells(0).innerText
            MsgBox data(x, 0)
        x = x   1
    Next
End Sub
  • Verified Answer

    I figured this out myself. My mistake; debugging in excel and forgetting its vbscript!

    the secret; open and close an HTMLFile object, then process that.

    Sub ExtractVersionFromHTML(HTMLToParse)
        Set oDOM = CreateObject("HTMLFile")
        oDOM.Write HTMLToParse
        oDOM.Close
    
        If oDOM.body.All.Length > 0 Then ' Process only HTML Content
            If oDOM.getelementsbytagname("table").Length > 0 Then ' Only process HTML that has a table in it
                x = 0
                ReDim data(oDOM.getelementsbytagname("table")(0).Rows.Length, 0)
                For Each oRow In oDOM.getelementsbytagname("table")(0).Rows
                    data(x, 0) = oRow.Cells(0).innerText
                    MsgBox data(x, 0)
                    x = x   1
                Next
            End If
        End If
    End Sub