所以此代码只在
之间检查一次 Private Function GetBetween(ByVal sSearch As String, ByVal sStart As String, _
ByVal sStop As String, Optional ByVal lSearch As Integer = 1) As String
Dim lTemp As Long
lSearch = InStr(lSearch, sSearch, sStart)
If lSearch > 0 Then
lSearch += Len(sStart)
lTemp = InStr(lSearch, sSearch, sStop)
If lTemp > lSearch Then
GetBetween = Trim(Mid(sSearch, lSearch, lTemp - lSearch))
End If
End If
End Function
我得到这个字符串字符串不稳定我的意思是可以有更多的玩家然后这个http://pastebin.com/JTi51nBV我想在播放器/播放器之间逐个显示文本,例如在messagebox中。 对不起我的英文
答案 0 :(得分:0)
使用正确的工具解析XML System.Xml.XmlDocument
:
' Add the namespace at the top
Imports System.Xml
' And then ...
Dim sXml As String = "YOUR_XML_STRING_HERE"
Dim doc As New XmlDocument
doc.PreserveWhitespace = True
doc.LoadXml(sXml)
For Each Entry As XmlNode In doc.SelectNodes("//player")
Console.WriteLine(Entry.InnerXml)
Next
请参阅VB.NET demo here。
如果您不需要显示代码,请将Entry.InnerXml
替换为Entry.InnerText
。
请注意,//player
是一个获取所有<player>
个节点的XPath表达式。