Hallo liebes Forum.
Und zwar habe ich mal wieder ein Problem bei einer xml datei auslesen.
Und zwar ist in der XML datei 2mal das wort "name" und ich will von beiden den namen rausfiltern und ins Label schreiben.
Es ist kein Bot bzw. es verschafft mir kein vorteil vom game her.
Es ist erlaubt von Pennergame solange man nicht die Server belastet.
Mein jetziger Source code ist so:
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <INet.au3>
#include <Array.au3>
#include <string.au3>
HotKeySet("{ESC}", "Terminate")
Func Terminate()
Exit 0
EndFunc
;~ Global $Pcode = "Dieter_Oleg4"
#Region --- CodeWizard generated code Start ---
;InputBox features: Title=Yes, Prompt=Yes, Default Text=No, Width=250, Height=140, Left=1, Top=1
If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer
$sInputBoxAnswer = InputBox("Pennergame","Wie heißen Sie in Pennergame Hamburg ?",""," ","250","140","1","1")
Select
Case @Error = 0 ;OK - The string returned is valid
Global $Pcode = $sInputBoxAnswer
Case @Error = 1 ;The Cancel button was pushed
Exit
Case @Error = 3 ;The InputBox failed to open
Exit
EndSelect
#EndRegion --- CodeWizard generated code End ---
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Pennergame", 250, 250, 1, 1)
Global $Label3 = GUICtrlCreateLabel("Label3", 5, 12, 306, 17)
Global $Label1 = GUICtrlCreateLabel("Label1", 5, 32, 306, 17)
Update()
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;~ Update()
AdlibRegister("Update", 60000) ; Jede Minute
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func Update()
;~ GUICtrlSetColor($LabelC, 0x000000)
For $i = 0 To 0
SetData($i)
Next
EndFunc ;==>Update
Func SetData($index)
$aTmp = _getXML_Weather_data($Pcode)
If IsArray($aTmp) Then
; aTmp 0 = city
; aTmp 1 = Punkte
; aTmp 2 = Name
; aTmp 3 = Id USER
; aTmp 4 = Regi since
; aTmp 5 = Position
GUICtrlSetData($Label1, $aTmp[1])
GUICtrlSetData($Label3, $aTmp[2])
Else
[/autoit] [autoit][/autoit] [autoit]MsgBox(0,"","Error 5")
[/autoit] [autoit][/autoit] [autoit]EndIf
EndFunc ;==>SetData
;~ http://www.pennergame.de/dev/api/user.getname.xml?name=nielz
Func _getXML_Weather_data($Pcode)
$Source = _INetGetSource("http://www.pennergame.de/dev/api/user.getname.xml?name=" & $Pcode) ;& '')
$ntype = _StringBetween($Source, '<problem_cause data="', '"/>')
If IsArray($ntype) Then
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(64, "Error", "Error 1." & @CRLF & @CRLF & "Error 5" & @CRLF & "Error 6," & @CRLF & "Error 6" & @CRLF & "Error 13" & @CRLF & @CRLF & "Error 25")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Return
EndIf
$Api = "http://www.pennergame.de/dev/api/user.getname.xml?name=" & $Pcode & ''
$XML_Source = _INetGetSource($Api)
$City = _StringBetween($XML_Source, '<city>', '</city>')
$Wstatus = _StringBetween($XML_Source, '<points>', '</points>')
$Temp = _StringBetween($XML_Source, '<name>', '</name>')
$Wind = _StringBetween($XML_Source, '<id>', '</id>')
$Humidity = _StringBetween($XML_Source, '<reg_since>', '</reg_since>')
$post = _StringBetween($XML_Source, '<position>', '</position>')
Local $MyWeather[6] = [$City[0], "Sie haben " & $Wstatus[0] & " Punkte", "Sie heißen " & $Temp[0] & "", $Wind[0], $Humidity[0], $post[0]]
Return $MyWeather
EndFunc ;==>_getXML_Weather_data
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit]Der aufbau der XML datei ist so:
Spoiler anzeigen
<!-- Pennergame XML API v0.2 -->
−
<Pennergame>
−
<user>
<id>2666957</id>
<name>supporter</name>
<cash>298727</cash>
<points>39769</points>
<position>238503</position>
<rankingpoints>0</rankingpoints>
<city>17</city>
<reg_since>27.11.2009</reg_since>
−
<gang>
<id>618347</id>
<name>Kalisser Bierstube</name>
<status>1</status>
<joined>27.11.2009</joined>
</gang>
</user>
</Pennergame>
Alles anzeigen