AutoHotkey Community

It is currently May 27th, 2012, 12:34 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: October 20th, 2006, 1:36 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
while playing with the XMLRead function from Titan,
i came up with a little function that downloads a RSS Feed
and stores its basic contents (title, description,url,image of the Feed and
tilte, description, url, genuine identifier, publication date, the type and url of an enclosed media file for each item of the feed)
in a set of global variables.

the function is based on examples given by Titan
and uses his XMLRead functon, http://www.autohotkey.net/~Titan/dl/XMLRead.ahk
which must be included.

Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795


Last edited by Zed Gecko on January 28th, 2012, 3:10 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 2:07 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Nice! :D It would be nice if you added a ListView of the output!
Just a suggestion... Thanks :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Full Demo
PostPosted: October 30th, 2006, 11:48 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
Yeah, well Goyyah is right, it´s a lousy demo,
so now comes the full "Simple RSS-Feed Reader".

I´ve added the listbox and some more.
Features:
- select a Feed-URL from a Dropdownlist
- add/delete URLs to/from this list
- show date and title of the feeds item in a list
- show description of the item in an editbox via left- or rightclick or rowselect
- open article in browser via doubleclick
- download and launch enclosed mediafiles (e.g. Podcasting)
- optional UTF-8 Encoding (thanks to PhiLhos code)

sorry for the lack of comment or structure,
but it´s only listviews and buttons anyway.
Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795



Last edited by Zed Gecko on January 28th, 2012, 3:11 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 31st, 2006, 2:17 pm 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
and because a lot of feeds seem to have html contents,
here is a version with an Explorer Control, to display everthing nicely.

It needs the AHKCtrlSupport.dll from Micha http://autohotkey.net/~Micha/CtrlSuppor ... upport.zip V1.23

Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795



Last edited by Zed Gecko on January 28th, 2012, 3:11 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 12:15 pm 
Offline

Joined: March 17th, 2007, 3:45 pm
Posts: 25
I can not find XMLRead function from Titan
:(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 2:33 pm 
luvan wrote:
I can not find XMLRead function from Titan
:(

As I recall, Titan lost or deleted most of his xml code and docs (you might PM him (or catch him on the #ahk irc channel) and ask if he still has the code), so here is what I had saved way back on 12/25/2007.
--------------------------------------------------------------------------------

Here is XMLRead() v2.04

Code:
XMLRead(source, tree, default = "") { ; v2.04 - by Titan
   If source is integer
   {
      DllCall("SetFilePointer", "UInt", source, "UInt", 0, "UInt", 0, "UInt", 0)
      s := VarSetCapacity(c, DllCall("GetFileSize", "UInt", source, "UInt", 0))
      DllCall("ReadFile", "UInt", source, "Str", c, "UInt", s, "UIntP", s, "UInt", 0)
   }
   Else FileRead, c, %source%
   StringGetPos, t, tree, @
   If (ErrorLevel = 0) {
      StringTrimLeft, a, tree, t + 1
      StringLeft, tree, tree, t
   }
   xc = %A_StringCaseSense%
   StringCaseSense, On
   d = >/%A_Tab%`r`n
   Loop, Parse, tree, .
   {
      e = %A_LoopField%
      i = 1
      StringGetPos, t, e, (
      If (ErrorLevel = 0) {
         StringMid, i, e, t + 2, InStr(e, ")") - t - 2
         StringLeft, e, e, t
         i++
      }
      Loop, Parse, d
         StringReplace, c, c, <%e%%A_LoopField%, <%e% %A_LoopField%, A
      ex := "<" . e . " "
      n = %A_Index%
      Loop {
         StringTrimLeft, c, c, InStr(c, ex, 1) -
         StringReplace, c, c, <, <, UseErrorLevel
         t = %ErrorLevel%
         StringReplace, c, c, />, />, UseErrorLevel
         t -= ErrorLevel
         StringReplace, c, c, </, </, UseErrorLevel
         If (t - ErrorLevel * 2) * -1 - n < 0 or x
            Break
         Else StringTrimLeft, c, c, 1
      }
      StringGetPos, t, c, %ex%, L%i%
      x += ErrorLevel
      StringTrimLeft, c, c, t
      t := InStr(c, "</" . e, 1)
      IfNotEqual, t, 0, StringLeft, c, c, t + StrLen(e) + 2
   }
   If a
      x := !(RegExMatch(c, ex . "[^>]*" . a . "=('|"")(.*?)\1", d) and c := d2)
   Else {
      t := InStr(c, "</" . e . ">", 1)
      x += !t
      StringMid, c, c, InStr(c, ">") + 1, t - 1 - InStr(c, ">")
   }
   StringCaseSense, %xc%
   If x
      c = %default%
   Return, c
}


and here is the doc page I saved
Code:
XMLRead() [version 2.0]
------------------------------------
Reads data from an XML document.
Result := XMLRead(Source, Tree [, Default])

Parameters
Result   The actual value returned by the function. 
Source   The name or handle of the file to read from. Performance is dramatically improved when using a file handle.   
Tree   The complete path of the node using the format parent.child(index)@attribute where each index starts at 0.   
Default   The value to return if there is an error.   

Related

FileRead, IniRead, RegRead, XMLWrite(), XML Tutorial

Examples
; Example 1: get settings from a custom XML file

settings = settings.xml ; file name
version := XMLRead(settings, "application@version") ; 'version' attribute of 'application'
tip_colour := XMLRead(settings, "application.interface.control(2).colour") ; third index of 'control'
close_msg := XMLRead(settings, "application.messages.close", "Closing...") ; using default value of 'Closing...'


; Example 2: aggregate a list of most-downloaded programs on download.com

#Include XMLRead.ahk ; includes the function

title = XML Reader Example
href = http://export.cnet.com/export/download/rss-hot-download.com.com.xml

TrayTip, %title% - Downloading...
   , Downloading RSS XML from:`n%href%, 10, 1
file = %A_Temp%\cnet_%A_Now%.xml
URLDownloadToFile, %href%, %file%
If ErrorLevel { ; if download was unsucessful...
   TrayTip
   MsgBox, 18, %title% - Error, Downloading failed?, 5
   IfMsgBox, Abort
      ExitApp
   IfMsgBox, Retry
      Reload
}

Gui, Font, s14 underline
Gui, Add, Text, vTitle gVisitMain, % XMLRead(file, "rss.channel.title") ; RSS title
Gui, Font
Gui, Add, ListView, w600 r10 gVisit, #|Title|Description|Published

items = 7 ; there number of item elements to parse ...
Loop, %items% {
   LV_Add("", A_Index
      , XMLRead(file, "rss.channel.item(" . A_Index - 1 . ").title") ; item title
      , XMLRead(file, "rss.channel.item(" . A_Index - 1 . ").description") ; item description
      , XMLRead(file, "rss.channel.item(" . A_Index - 1 . ").pubDate")) ; item pubdate (date published)
   link%A_Index% := XMLRead(file, "rss.channel.item(". A_Index - 1 . ").link") ; store the item URL
}

IL := IL_Create(items)
LV_SetImageList(IL)
Loop, %items%
   IL_Add(IL, "shell32.dll", 14)

Loop, 4
   LV_ModifyCol(A_Index, "AutoHdr") ; auto-adjust columns

basex := XMLRead(file, "rss.channel.link") ; main URL
SplitPath, basex, , , , , base
StringReplace, base, base, http://
StringReplace, base, base, www.
StringReplace, base, base, /

Gui, Add, Button, Section w50 gGuiClose Default, &Close
Gui, Add, Text, ys+5, Double-click an item to view it on %base%
RSS := XMLRead(file, "rss@version") ; RSS version (attribute)
FileDelete, %file%
TrayTip
Gui, Show, , %title% - RSS Version %RSS%
Return

VisitMain:
Run, %basex%
Return

Visit:
If A_GuiEvent = DoubleClick
   Run, % link%A_EventInfo% ; opens item's link
Return

GuiClose:
ExitApp


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2009, 10:49 am 
Offline

Joined: March 17th, 2007, 3:45 pm
Posts: 25
Thanks! :lol:


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Cristi®, Google Feedfetcher, Stigg and 46 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group