
Brantus
Minmatar the united Negative Ten.
|
Posted - 2011.06.21 22:56:00 -
[1]
This is Dalryn's main..
I decided to stop being just a nay sayer and give you a nudge with using a datacontractserializer.
I don't believe the issues are related to .NET since I'm using VS2010 with .NET 4.0 to build the solution on sourceforge.
Anyway, here's a class that will give you the names of all the characters returned by Characters.xml
Just construct the class with the result of your API call.
Quote:
Imports System.IO Imports System.Xml.Schema Imports System.Xml.Serialization Imports System.Runtime.Serialization
Public Class xmlParser Public api As eveapi
Public Sub New(ByVal eveApiXmlResponse As String) api = parseXml(eveApiXmlResponse)
For Each charList As characterList In api.characterLists For Each eveChar As eveCharacter In charList.characters MessageBox.Show(eveChar.name) Next Next End Sub
Private Function parseXml(ByVal eveResponse As String) As eveapi Dim xmlRoot As XmlRootAttribute = New XmlRootAttribute xmlRoot.ElementName = "eveapi" xmlRoot.IsNullable = True Dim serializer As New XmlSerializer(GetType(eveapi), xmlRoot) Dim ms As New MemoryStream(System.Text.Encoding.UTF8.GetBytes(eveResponse))
Return CType(serializer.Deserialize(ms), eveapi) End Function End Class
Partial Public Class eveapi Public Property currentTime As String Public Property cachedUntil As String
<System.Xml.Serialization.XmlArrayAttribute("result", Form:=XmlSchemaForm.Unqualified), _ System.Xml.Serialization.XmlArrayItemAttribute("rowset", GetType(characterList), Form:=XmlSchemaForm.Unqualified)> _ Public Property characterLists As List(Of characterList)
Public Property version As String
End Class
<XmlTypeAttribute(AnonymousType:=True)> _ Partial Public Class characterList <System.Xml.Serialization.XmlElementAttribute("row", Form:=XmlSchemaForm.Unqualified)> _ Public Property characters As List(Of eveCharacter)
Public Property name As String Public Property key As String Public Property columns As String End Class
<XmlTypeAttribute(AnonymousType:=True)> _ Partial Public Class eveCharacter
<XmlAttributeAttribute()> _ Public Property name As String
<XmlAttributeAttribute()> _ Public Property characterID As String
<XmlAttributeAttribute()> _ Public Property corporationName As String
<XmlAttributeAttribute()> _ Public Property corporationID As String
End Class
|