Die Parameter von CatchXML() sind ja (#XML, *Adresse, Laenge [, Flags [, Kodierung]])
Da hab ich nun mit rumexperimentiert ... und siehe da :
und schon wird alles angezeigt (bzw. von deinem Bsp. ausgelesen) wie es sein soll...
Ich hab meinen Code von oben ein wenig überarbeitet, Stargates Hinweis übernommen (hier ts-soft sei gedankt) und ein
hoffentlich einwandfreies Include gebastelt, das auch ein Anfänger verstehen könnte (von der Fremdprozedur mal abgesehen
Code: Alles auswählen
EnableExplicit
;###############################################################################
;#####
;##### Benötigte Prozeduren zum Netzwerk Initialisieren und Download2Memory
;#####
;###############################################################################
Procedure.i NetWorkInit()
Static Netz
If Netz <> #True
If InitNetwork() = 0
Netz = #False
MessageRequester("Network","No TCP-Stack found !",#MB_ICONSTOP)
End
Else
Netz = #True
EndIf
EndIf
ProcedureReturn Netz
EndProcedure
Procedure.i ReceiveHTTPMemory(URL.s, BufferSize = 4096, Timeout = 5000)
;##### Original von ts-soft
If NetWorkInit()
Protected Connection, Time, Time2, Event, Size, Size2, SizeAll, pos
Protected.s Server
Protected *Mem, *Buffer, *Mem2
Size = 1
If LCase(Left(URL, 7)) <> "http://" : URL = "http://" + URL : EndIf
Server = GetURLPart(URL, #PB_URL_Site)
If Not Server : ProcedureReturn #False : EndIf
Connection = OpenNetworkConnection(Server, 80, #PB_Network_TCP)
If Not Connection : ProcedureReturn #False : EndIf
If BufferSize <= 0 : BufferSize = 4096 : EndIf
*Buffer = AllocateMemory(BufferSize)
If Not *Buffer : ProcedureReturn #False : EndIf
SendNetworkString(Connection, "GET " + URL + " HTTP/1.0" + #LFCR$ + #LFCR$)
Time = ElapsedMilliseconds()
Repeat
Event = NetworkClientEvent(Connection)
If Event = #PB_NetworkEvent_Data
Repeat
Size = ReceiveNetworkData(Connection, *Buffer, BufferSize)
If Size > 0
Time = ElapsedMilliseconds()
SizeAll + Size
*Mem = ReAllocateMemory(*Mem, SizeAll)
If *Mem
CopyMemory(*Buffer, *Mem + (SizeAll - Size), Size)
Else
CloseNetworkConnection(Connection)
FreeMemory(*Buffer)
ProcedureReturn #False
EndIf
EndIf
Until Size <= 0
EndIf
Time2 = ElapsedMilliseconds() - Time
Until Time2 > Timeout Or Size <= 0
CloseNetworkConnection(Connection)
FreeMemory(*Buffer)
If Time2 > Timeout
If *Mem : FreeMemory(*Mem) : EndIf
ProcedureReturn #False
EndIf
pos = FindString(PeekS(*mem, -1, #PB_UTF8), #CRLF$ + #CRLF$, 1) - 1
pos = Len(#CRLF$ + #CRLF$) + pos
Size2 = MemorySize(*Mem) - pos
*Mem2 = AllocateMemory(Size2)
If *Mem2
CopyMemory(*Mem + pos, *Mem2, Size2)
FreeMemory(*Mem)
ProcedureReturn *Mem2
EndIf
FreeMemory(*Mem)
EndIf
ProcedureReturn #False
EndProcedure
;###############################################################################
;#####
;##### iGoogle Wetterdaten
;#####
;###############################################################################
UsePNGImageDecoder()
Structure iGoogle_wetter_daten
current_date_time.s
city.s
postal_code.s
Unit_System.s
ccondition.s
temp_f.i
temp_c.i
humidity.i
cicon.s
cimage.i
wind_condition.s
day_of_week.s[5]
low.i[5]
high.i[5]
icon.s[5]
image.i[5]
condition.s[5]
EndStructure
Global NewMap iGoogle_Weather_Data.iGoogle_wetter_daten()
Procedure.s iGoogle_Weather_ParseData(String.s)
Protected Result.s = ""
Result = Mid(String,FindString(String,Chr(32),1))
Result = RemoveString(Result,"data=")
Result = RemoveString(Result,"/>")
Result = RemoveString(Result,#DQUOTE$)
Result = Trim(Result)
ProcedureReturn Result
EndProcedure
Procedure.s iGoogle_Weather_ParseNode(String.s)
Protected Result.s = ""
Result = StringField(String,1," ")
Result = RemoveString(Result,"<")
Result = Trim(Result)
ProcedureReturn Result
EndProcedure
Procedure iGoogle_Weather_forecast_information(Location.s, Array XML.s(1), Start,Stop)
Protected Mark.s, Result.s, i.i, Datum.i
With iGoogle_Weather_Data(Location)
For i=Start To Stop
Result.s = iGoogle_Weather_ParseData(xml(i))
Mark.s = iGoogle_Weather_ParseNode(xml(i))
Select Mark
Case "city"
\city = result
Case "postal_code"
\postal_code = result
Case "current_date_time"
Datum = ParseDate("%yyyy-%mm-%dd %hh:%ii:%ss", Result)
\current_date_time = FormatDate("%dd.%mm.%yyyy - %hh:%ii:%ss",Datum)
Case "unit_system"
\Unit_System = result
EndSelect
Next i
EndWith
EndProcedure
Procedure iGoogle_Weather_current_conditions(Location.s, Array XML.s(1), Start,Stop)
Protected Mark.s, Result.s, i.i
Protected *BildAdresse
With iGoogle_Weather_Data(Location)
For i=Start To Stop
Result.s = iGoogle_Weather_ParseData(xml(i))
Mark.s = iGoogle_Weather_ParseNode(xml(i))
Select Mark
Case "condition"
\ccondition = result
Case "temp_f"
\temp_f = Val(result)
Case "temp_c"
\temp_c = Val(result)
Case "humidity"
result = Trim(RemoveString(StringField(result,2,":"),"%"))
\humidity = Val(result)
Case "icon"
\cicon = "http://img0.gmodules.com"+Result
*BildAdresse = ReceiveHTTPMemory(Left(\cicon,Len(\cicon)-3) + "png")
If *BildAdresse
\cimage = CatchImage(#PB_Any,*BildAdresse)
FreeMemory(*BildAdresse)
EndIf
Case "wind_condition"
\wind_condition = result
EndSelect
Next i
EndWith
EndProcedure
Procedure iGoogle_Weather_forecast_conditions(Location.s, Array XML.s(1), Tag, Start,Stop)
Protected Mark.s, Result.s, i.i
Protected *BildAdresse
If Tag <=4
With iGoogle_Weather_Data(Location)
For i=Start To Stop
Result.s = iGoogle_Weather_ParseData(xml(i))
Mark.s = iGoogle_Weather_ParseNode(xml(i))
Select Mark
Case "day_of_week"
\day_of_week[Tag] = Result
Case "low"
\low[Tag] = Val(Result)
Case "high"
\high[Tag] = Val(Result)
Case "icon"
\icon[Tag] = "http://img0.gmodules.com"+Result
*BildAdresse = ReceiveHTTPMemory(Left(\icon[Tag],Len(\icon[Tag])-3) + "png")
If *BildAdresse
\image[Tag] = CatchImage(#PB_Any,*BildAdresse)
FreeMemory(*BildAdresse)
EndIf
Case "condition"
\condition[Tag] = Result
EndSelect
Next i
EndWith
EndIf
EndProcedure
Procedure iGoogle_Weather(Location.s, Language.s = "de")
Protected Url.s = "http://www.google.com/ig/api?weather=" + Location + "&hl=" + Language
Protected *Adresse = ReceiveHTTPMemory(Url)
Protected String.s, Anz.i, i.i, Start.i, Stop.i, Nr.i
If *Adresse
String.s = PeekS(*Adresse)
FreeMemory(*Adresse)
EndIf
If String <> ""
Anz = CountString(String,">")
Dim XML.s(Anz)
For i=1 To Anz
XML(i) = StringField(String,i,">")+">"
Next i
For i=1 To Anz
If XML(i) = "<forecast_information>"
Start = i+1
Repeat
i + 1
Until XML(i) = "</forecast_information>"
Stop = i-1
iGoogle_Weather_forecast_information(Location,xml(),start,stop)
EndIf
If XML(i) = "<current_conditions>"
Start = i+1
Repeat
i + 1
Until XML(i) = "</current_conditions>"
Stop = i-1
iGoogle_Weather_current_conditions(Location,xml(),start,stop)
EndIf
If XML(i) = "<forecast_conditions>"
Start = i+1
nr + 1
Repeat
i + 1
Until XML(i) = "</forecast_conditions>"
Stop = i-1
iGoogle_Weather_forecast_conditions(Location,xml(),Nr,start,stop)
EndIf
Next i
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
;#####
;##### Beispiel
;#####
Define Location.s, Event.i, Quit.i, i.i
Location.s = "Berlin"
If iGoogle_Weather(Location)
OpenWindow(0,0,0,300,500,"Wetter : "+Location,#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
With iGoogle_Weather_Data(Location)
If IsImage(\cimage)
ImageGadget(0,10,10,40,40,ImageID(\cimage))
EndIf
TextGadget(1,55,10,250,15,\current_date_time)
TextGadget(2,55,25,250,15,\ccondition)
TextGadget(3,55,40,250,15,Str(\temp_c) + " Grad Celsius bei "+Str(\humidity)+"% Luftfeuchtigkeit")
TextGadget(4,55,55,250,15,"Wind aus "+\wind_condition)
TextGadget(5,55,90,250,15,"Weitere Vorhersagen :")
For i=1 To 4
If IsImage(\cimage)
ImageGadget(i+5,10,100+(i*50),40,40,ImageID(\image[i]))
EndIf
TextGadget(i+5+4,55,100+(i*50),250,15,\day_of_week[i]+" : "+Str(\low[i])+" | "+Str(\high[i])+" Grad Celsius")
TextGadget(i+5+4+4,55,120+(i*50),250,15,\condition[i])
Next i
EndWith
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf