有没有更好的方法来使用Visual Basic提取HTML代码

时间:2015-07-02 16:17:12

标签: html xml vb.net visual-studio

我正在尝试在这里提取一些HTML代码,我只想说最终的String '实体B'。有没有比我在这里做的更好的方法呢? 这也是许多条目的格式,因此实体B不一定是实体B,对于实体C也是如此

SELECT daf.id as affiliate_id,
   daf.name as affiliate_name,
   dal.name as allocation_name,
   dal.id as allocation_id,
   dal.allocation
   ,dal.price
   ,ap.lead_Price
   ,ap.live 
   ,ap.allocation 
FROM 

     degreeamerica.affiliates daf
     JOIN paul.affiliates_price ap
     ON daf.id = ap.affiliate_id
     JOIN degreeamerica.allocations dal
     ON dal.id = ap.allocation_id

ORDER BY daf.id;

1 个答案:

答案 0 :(得分:0)

我并非100%清楚您的最终游戏是什么,但至于您的问题的第一句话,您想要在其中包含HTML代码的字符串并删除所有代码,此功能将删除任何<>中包含的标记:

Public Function RemoveHTML(ByVal input As String) As String
    While InStr(input, "<") > 0
        Dim tagStart As Integer = InStr(input, "<")
        Dim tagEnd As Integer = InStr(input, ">")
        input = Left(input, tagStart - 1) & Right(input, Len(input) - tagEnd)
    End While
    Return input
End Function

如果您还试图在<br/>标记之后删除任何内容,则会执行此操作:

Public Function OneEntity(ByVal input As String) As String
    If InStr(input, "<br/>" Then
        Dim parts() As String = Split(input, "<br/>")
        Return RemoveHTML(parts(0))
    Else
        Return RemoveHTML(input)
    End If
End Function