This is a very practical way to parse XML files. Similar approach is also used in perl. Thank you very much for making this library available for Purebasic community. I'll be using it very much and believe it's a heaven-sent library for many developers.Flype wrote:Here is a small example to introduce PureXML2.
This shows how to very easily retrieves partial informations
from a distant XML document using ParseUrl() and the CharacterData handler.
Code: Select all
Global result$ Procedure.l Extract_From_IpPages(name.s, string.s, length.l) Select name ; tag name Case "ip": result$ + "IP V4: " + #TAB$ + string + #CRLF$ Case "ip_long": result$ + "IP: " + #TAB$ + string + #CRLF$ Case "ipv6": result$ + "IP V6: " + #TAB$ + string + #CRLF$ Case "host": result$ + "HOST: " + #TAB$ + string + #CRLF$ Case "isp": result$ + "ISP: " + #TAB$ + string + #CRLF$ Case "country": result$ + "CTRY: " + #TAB$ + string + #CRLF$ EndSelect EndProcedure If MessageRequester("Question", "Resolves your IP Address from `ippages.com` ?", #MB_OKCANCEL|#MB_ICONQUESTION) = #IDOK PureXML_SetCharacterDataHandler(@Extract_From_IpPages()) If PureXML_ParseUrl("http://www.ippages.com/xml/") If MessageRequester("Copy the result to the clipboard ?", result$, #MB_OKCANCEL|#MB_ICONINFORMATION) = #IDOK SetClipboardText(result$) EndIf Else MessageRequester("Error", PureXML_GetErrorString(), #MB_ICONERROR) EndIf EndIf
-davenull-