【发布时间】:2021-01-22 08:40:49
【问题描述】:
<tr class="sh"onclick="ii.ShowShareHolder('7358,IRO1GNBO0008')">
<td>ghanisha sherkat-</td>
<td><div class='ltr' title="141,933,691">142 M</div></td>
<td>52.560</td>
<td>0</td>
<td><div class=""/></td>
</tr>
我们希望在上述文本项下输出:
ghanisha sherkat
141,933,691
52.560
0
我的尝试:
Dim input as string="above text"
Dim c2 As String() = input.Split(New String() {"</td>"},StringSplitOptions.None)
Dim r As Integer
For r = 0 To c2.Length - 2
MessageBox.Show(c2(r))
Next
其他我的尝试
Dim sDelimStart As String = "<td>"
Dim sDelimEnd As String = "</td>"
Dim nIndexStart As Integer = input.IndexOf(sDelimStart)
Dim nIndexEnd As Integer = input.IndexOf(sDelimEnd)
Res = Strings.Mid(input, nIndexStart + sDelimStart.Length + 1, nIndexEnd - nIndexStart - sDelimStart.Length)
MessageBox.Show(res)
通过这种方式提取“ghanisha sherkat”
如何提取其他物品?
现在怎么继续呢?谢谢
【问题讨论】:
-
没有人帮助我吗?
-
在解析标记语言时应避免在文本内搜索或使用正则表达式。相反,如果您有可用的解析器,请使用它来解析标记并提取元素和属性。我在回答中提供了两种方法;一种使用
XmlDocument和一些XPath,另一种使用您不应该使用的正则表达式。
标签: vb.net html-parsing