Как насчет другого подхода? Обработка потока, как вы сейчас делаете, кажется довольно сложной работой.
Если вместо этого вы прочитаете весь поток в строку, а затем загрузите эту строку в XDocument , вы сможете обработать файл намного проще.
VB позволяет вам получить доступ к данным из файлов XML очень простым способом, взгляните на следующий код, чтобы понять, что я имею в виду:
' get the response stream so we can read it
Dim responseStream = response.GetResponseStream()
' create a stream reader to read the response
Dim responseReader = New IO.StreamReader(responseStream)
' read the response text (this should be javascript)
Dim responseText = responseReader.ReadToEnd()
' load the response into an XDocument
Dim xmlDocument = XDocument.Parse(responseText)
' find all the player objects from the document
For Each playerObject In xmlDocument...<object>
' display the player's name (this is how you access an attribute)
Console.WriteLine("Player name: {0}", playerObject.@name)
' display the player's status (this is how you access an element)
Console.WriteLine("Player status: {0}", playerObject.<status>.Value)
Next
Чтобы получить свойства своего игрока, вы можете сделать следующее:
' go through the player's properties
For Each playerProperty In playerObject...<property>
' output the values
Console.WriteLine("Player property name: {0}", playerProperty.@name)
Console.WriteLine("Player property value: {0}", playerProperty.@value)
Next
Как кто-то еще упомянул, ваш Xml поврежден, но XDocument сообщит вам об этом, чтобы вы могли это исправить.