sonicxtacy02 Posted September 12, 2006 Share Posted September 12, 2006 here's my code so far expandcollapse popup#include <GUIConstants.au3> Global $trafficfile= "C:\Program Files\Road Runner\livetraffic\trafficland.txt" global $tested, $Result, $resultpre ; == GUI generated with Koda == $Form1 = GUICreate("AForm1", 622, 448, 192, 125) GUICtrlCreateLabel("Enter Search Criteria (Cam Number, Street name, Etc.)", 16, 24, 586, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $Input1 = GUICtrlCreateInput("", 16, 72, 593, 32, -1, $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Search = GUICtrlCreateButton("Search", 200, 112, 169, 65) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $List1 = GUICtrlCreateList("", 96, 192, 393, 162, -1, $WS_EX_CLIENTEDGE) $Ok = GUICtrlCreateButton("OK", 224, 368, 145, 57) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Search $Query=guictrlread(4) Get_List() msgbox(0,"TEST", $result) Case $msg = $Input1 ;;;;;;; EndSelect WEnd Exit Func Get_List() ;================================================================== ;=== get playlistpath form rr.ini ;================================================================== $num_entery = _FileCountLines($trafficfile)+1 $ln=1 Do $var = FileReadLine($trafficfile,$ln) $ln = $ln + 1 If StringInStr($var,$Query) Then $Resultpre = StringMid($var,18) $result= stringtrimright($resultpre,13) if @error then $result="Camera Not Found" Until $ln = $num_entery EndFunc Func _FileCountLines($sFilePath) Local $N = FileGetSize($sFilePath) - 1 If @error Or $N = -1 Then Return 0 Return StringLen(StringAddCR(FileRead($sFilePath, $N))) - $N + 1 EndFunc ;==>_FileCountLines This code successfully returns the first Sentence containing the searchword from a text file. However, i need the get_lists function to give me the results EVERY time the keyword is found in the file (as opposed to just the first time). How would i go about doing this? Right now i'm just writing the files to a msgbox, but later i plan on displaying the results of the search in my listbox. Link to comment Share on other sites More sharing options...
sulfurious Posted September 12, 2006 Share Posted September 12, 2006 If I understand you correctly, you have a text file with a keyword that can be present more than once. And you wish to search for this keyword and return every line that has an instance of it? If that is the case, make an array and in your function, pass every line with the keyword into the array. Then you can dump the array out into whatever you wish and even do some string manipulation to each line if you wish. Something like this #include <array.au3> Dim $arr[10] $a = 0 $f = FileOpen(@DesktopDir & "\kim.txt",0) While 1 $l = FileReadLine($f) If @error = -1 Then ExitLoop If StringInStr($l,"rex") Then $arr[$a] = $l $a = $a + 1 EndIf WEnd For $i = 0 to UBound($arr) - 1 MsgBox(0,"",$arr[$i]) Next Where kim.txt is thisThis is rex. This is joe. This is not rex. This is not joe. This may be rex. This may be joe. Bear in mind you will have to logically manipulate the dimension of the array if it will be dynamic. late, Sul Link to comment Share on other sites More sharing options...
sonicxtacy02 Posted September 12, 2006 Author Share Posted September 12, 2006 (edited) If I understand you correctly, you have a text file with a keyword that can be present more than once. And you wish to search for this keyword and return every line that has an instance of it? If that is the case, make an array and in your function, pass every line with the keyword into the array. Then you can dump the array out into whatever you wish and even do some string manipulation to each line if you wish. Something like this #include <array.au3> Dim $arr[10] $a = 0 $f = FileOpen(@DesktopDir & "\kim.txt",0) While 1 $l = FileReadLine($f) If @error = -1 Then ExitLoop If StringInStr($l,"rex") Then $arr[$a] = $l $a = $a + 1 EndIf WEnd For $i = 0 to UBound($arr) - 1 MsgBox(0,"",$arr[$i]) Next Where kim.txt is thisThis is rex. This is joe. This is not rex. This is not joe. This may be rex. This may be joe. Bear in mind you will have to logically manipulate the dimension of the array if it will be dynamic. late, Sul This works, but the message box returns the entire line, i need to return a substring from within that line. For example, keyword is dale. This is what is returned <CameraName>Colesville Rd (Us 29) and Dale Dr</CameraName> i need only whats in the cameraname tags. How do i trim the string ($i in your example) before dumping it in a msgbox? Bare with me this is my first time working with arrays. Edited September 12, 2006 by sonicxtacy02 Link to comment Share on other sites More sharing options...
lod3n Posted September 12, 2006 Share Posted September 12, 2006 Put the _SRE_Between function outside your loop, at the end. $string = _SRE_Between($arr[$i], "<CameraName>", "</CameraName>") MsgBox(0,"",$string) Func _SRE_Between($s_String, $s_Start, $s_End, $i_ReturnArray = 0); $i_ReturnArray returns an array of all found if it = 1, otherwise default returns first found $a_Array = StringRegExp($s_String, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3) If Not @error And Not $i_ReturnArray And IsArray($a_Array) Then Return $a_Array[0] If IsArray($a_Array) Then Return $a_Array EndFunc [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
sonicxtacy02 Posted September 12, 2006 Author Share Posted September 12, 2006 Put the _SRE_Between function outside your loop, at the end. $string = _SRE_Between($arr[$i], "<CameraName>", "</CameraName>") MsgBox(0,"",$string) Func _SRE_Between($s_String, $s_Start, $s_End, $i_ReturnArray = 0); $i_ReturnArray returns an array of all found if it = 1, otherwise default returns first found $a_Array = StringRegExp($s_String, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3) If Not @error And Not $i_ReturnArray And IsArray($a_Array) Then Return $a_Array[0] If IsArray($a_Array) Then Return $a_Array EndFunc Great. That worked perfectly! Link to comment Share on other sites More sharing options...
sonicxtacy02 Posted September 13, 2006 Author Share Posted September 13, 2006 Looks like i need a bit more help. I'm using the same functions with a different .txt file. The functions still work, however each msgbox is repeated 5 times. It seems as if The white space before the <title> tag is being treated as individual lines. My question now is how do i get the msgbox to only appear every 5th time? This is the only way i can think of handling this because i cant edit the .txt file format. Here's the new code expandcollapse popupGlobal $string ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-START: C:\Documents and Settings\Administrator.SXWORK\Desktop\trdetails.au3> ; ---------------------------------------------------------------------------- InetGet("http://www.traffic.com/feeds/rss_washingtondc.xml", "C:\Program Files\Road Runner\Control\trdetails.txt", 1) ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-END: C:\Documents and Settings\Administrator.SXWORK\Desktop\trdetails.au3> ; ---------------------------------------------------------------------------- Dim $arr[32] $a=0 $f = FileOpen("C:\Program Files\Road runner\control\trdetails.txt",0) $query="Jam" while 1 $l = FileReadLine($f) If @error = -1 Then ExitLoop If StringInStr($l,$query) Then $arr[$a] = $l $a = $a + 1 endif WEnd For $i = 0 to UBound($arr) - 1 $string = _SRE_Between($arr[$i], "<title>", "</title>") if not $string="" then msgbox(0,"TEST", $string) Next Func _SRE_Between($s_String, $s_Start, $s_End, $i_ReturnArray = 0); $i_ReturnArray returns an array of all found if it = 1, otherwise default returns first found $a_Array = StringRegExp($s_String, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3) If Not @error And Not $i_ReturnArray And IsArray($a_Array) Then Return $a_Array[0] If IsArray($a_Array) Then Return $a_Array return $string EndFunc and the .txt file expandcollapse popup<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="http://cityrss.traffic.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://cityrss.traffic.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"> <channel> <title>Traffic Conditions - Washington</title> <description><![CDATA[Traffic incident and event information for the Washington metro area.]]></description> <link>http://www.traffic.com</link> <pubDate>Wed, 13 Sep 2006 11:04:56 EDT</pubDate> <webMaster>support@traffic.com</webMaster> <image> <title><![CDATA[Traffic.com]]></title> <url>http://www.traffic.com/images/motech_fulllogo.gif</url> <link>http://www.traffic.com</link> <width>144</width> <height>82</height> </image> <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://cityrss.traffic.com/feeds/rss_washingtondc" type="application/rss+xml" /><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site, subject to copyright and fair use.</feedburner:browserFriendly><item> <title>Southeast/Southwest Frwy EASTBOUND from 14th St Brg to Pennsylvania Av: Jam Factor 0.3 - Wed, 13 Sep 2006 11:04:56 EDT</title> <description> Southeast/Southwest Frwy EASTBOUND from 14th St Brg to Pennsylvania Av: Jam Factor 0.3 - Incidents: 0 </description> <link>http://cityrss.traffic.com/feeds/rss_washingtondc?m=28</link> <pubDate>Wed, 13 Sep 2006 11:04:56 EDT</pubDate> <content:encoded><![CDATA[ <p><strong>Southeast/Southwest Frwy EASTBOUND from 14th St Brg to Pennsylvania Av</strong></p> <p><a href="http://www.traffic.com/Washington-DC-Traffic/Southeast_Southwest_Frwy-1.html"><img src="http://rss.traffic.com/images/jamFactors/jamFactor0.3.jpg" alt="jam factor" border="0" width="150" height="35" /></a><br /> - Jam Factor: 0.3<br /> - Incidents: 0 </p> <p><a href="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?a=QNiqfd"><img src="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?i=QNiqfd" border="0"></img></a></p> <div class="feedflare"><a href="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?a=66P9C4DO"><img src="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?i=66P9C4DO" border="0"></img></a></div><img src="http://cityrss.traffic.com/feeds/rss_washingtondc?g=28"/>]]></content:encoded> <feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=feeds/rss_washingtondc&itemurl=http%3A%2F%2Fwww.traffic.com%2FWashington-DC-Traffic%2FSoutheast_Southwest_Frwy-1.html</feedburner:awareness><feedburner:origLink>http://www.traffic.com/Washington-DC-Traffic/Southeast_Southwest_Frwy-1.html</feedburner:origLink></item> <item> <title>Southeast/Southwest Frwy WESTBOUND from Pennsylvania Av to 14th St Brg: Jam Factor 0.0 - Wed, 13 Sep 2006 11:04:56 EDT</title> <description> Southeast/Southwest Frwy WESTBOUND from Pennsylvania Av to 14th St Brg: Jam Factor 0.0 - Incidents: 0 </description> <link>http://cityrss.traffic.com/feeds/rss_washingtondc?m=29</link> <pubDate>Wed, 13 Sep 2006 11:04:56 EDT</pubDate> <content:encoded><![CDATA[ <p><strong>Southeast/Southwest Frwy WESTBOUND from Pennsylvania Av to 14th St Brg</strong></p> <p><a href="http://www.traffic.com/Washington-DC-Traffic/Southeast_Southwest_Frwy-2.html"><img src="http://rss.traffic.com/images/jamFactors/jamFactor0.0.jpg" alt="jam factor" border="0" width="150" height="35" /></a><br /> - Jam Factor: 0.0<br /> - Incidents: 0 </p> <p><a href="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?a=eB8iXb"><img src="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?i=eB8iXb" border="0"></img></a></p> <div class="feedflare"><a href="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?a=rGJJAQuT"><img src="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?i=rGJJAQuT" border="0"></img></a></div><img src="http://cityrss.traffic.com/feeds/rss_washingtondc?g=29"/>]]></content:encoded> <feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=feeds/rss_washingtondc&itemurl=http%3A%2F%2Fwww.traffic.com%2FWashington-DC-Traffic%2FSoutheast_Southwest_Frwy-2.html</feedburner:awareness><feedburner:origLink>http://www.traffic.com/Washington-DC-Traffic/Southeast_Southwest_Frwy-2.html</feedburner:origLink></item> <item> <title>I-66 EASTBOUND from Bus. RT-234 (#47) to Theodore Roosevelt Brg: Jam Factor 6.3 - Wed, 13 Sep 2006 11:04:56 EDT</title> <description> I-66 EASTBOUND from Bus. RT-234 (#47) to Theodore Roosevelt Brg: Jam Factor 6.3 - Incidents: 3 (Moderate) </description> <link>http://cityrss.traffic.com/feeds/rss_washingtondc?m=30</link> <pubDate>Wed, 13 Sep 2006 11:04:56 EDT</pubDate> <content:encoded><![CDATA[ <p><strong>I-66 EASTBOUND from Bus. RT-234 (#47) to Theodore Roosevelt Brg</strong></p> <p><a href="http://www.traffic.com/Washington-DC-Traffic/I-66-1.html"><img src="http://rss.traffic.com/images/jamFactors/jamFactor6.3.jpg" alt="jam factor" border="0" width="150" height="35" /></a><br /> - Jam Factor: 6.3<br /> - Incidents: 3 (Moderate) </p> <p><a href="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?a=XEpTsh"><img src="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?i=XEpTsh" border="0"></img></a></p> <div class="feedflare"><a href="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?a=yfnuSOPy"><img src="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?i=yfnuSOPy" border="0"></img></a></div><img src="http://cityrss.traffic.com/feeds/rss_washingtondc?g=30"/>]]></content:encoded> <feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=feeds/rss_washingtondc&itemurl=http%3A%2F%2Fwww.traffic.com%2FWashington-DC-Traffic%2FI-66-1.html</feedburner:awareness><feedburner:origLink>http://www.traffic.com/Washington-DC-Traffic/I-66-1.html</feedburner:origLink></item> <item> <title>I-66 WESTBOUND from Theodore Roosevelt Brg to Bus. RT-234 (#47): Jam Factor 0.3 - Wed, 13 Sep 2006 11:04:56 EDT</title> <description> I-66 WESTBOUND from Theodore Roosevelt Brg to Bus. RT-234 (#47): Jam Factor 0.3 - Incidents: 1 (Moderate) </description> <link>http://cityrss.traffic.com/feeds/rss_washingtondc?m=31</link> <pubDate>Wed, 13 Sep 2006 11:04:56 EDT</pubDate> <content:encoded><![CDATA[ <p><strong>I-66 WESTBOUND from Theodore Roosevelt Brg to Bus. RT-234 (#47)</strong></p> <p><a href="http://www.traffic.com/Washington-DC-Traffic/I-66-2.html"><img src="http://rss.traffic.com/images/jamFactors/jamFactor0.3.jpg" alt="jam factor" border="0" width="150" height="35" /></a><br /> - Jam Factor: 0.3<br /> - Incidents: 1 (Moderate) </p> <p><a href="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?a=y699BE"><img src="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?i=y699BE" border="0"></img></a></p> <div class="feedflare"><a href="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?a=IjTglrkd"><img src="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?i=IjTglrkd" border="0"></img></a></div><img src="http://cityrss.traffic.com/feeds/rss_washingtondc?g=31"/>]]></content:encoded> <feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=feeds/rss_washingtondc&itemurl=http%3A%2F%2Fwww.traffic.com%2FWashington-DC-Traffic%2FI-66-2.html</feedburner:awareness><feedburner:origLink>http://www.traffic.com/Washington-DC-Traffic/I-66-2.html</feedburner:origLink></item> <item> <title>I-95 (MD) SOUTHBOUND from I-695 Beltway (#49) to I-495 Capital Beltway: Jam Factor 0.8 - Wed, 13 Sep 2006 11:04:56 EDT</title> <description> I-95 (MD) SOUTHBOUND from I-695 Beltway (#49) to I-495 Capital Beltway: Jam Factor 0.8 - Incidents: 1 (Moderate) </description> <link>http://cityrss.traffic.com/feeds/rss_washingtondc?m=55</link> <pubDate>Wed, 13 Sep 2006 11:04:56 EDT</pubDate> <content:encoded><![CDATA[ <p><strong>I-95 (MD) SOUTHBOUND from I-695 Beltway (#49) to I-495 Capital Beltway</strong></p> <p><a href="http://www.traffic.com/Washington-DC-Traffic/I-95_(MD)-2.html"><img src="http://rss.traffic.com/images/jamFactors/jamFactor0.8.jpg" alt="jam factor" border="0" width="150" height="35" /></a><br /> - Jam Factor: 0.8<br /> - Incidents: 1 (Moderate) </p> <p><a href="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?a=736Qhi"><img src="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?i=736Qhi" border="0"></img></a></p> <div class="feedflare"><a href="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?a=mGo7Jp5D"><img src="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?i=mGo7Jp5D" border="0"></img></a></div><img src="http://cityrss.traffic.com/feeds/rss_washingtondc?g=55"/>]]></content:encoded> <feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=feeds/rss_washingtondc&itemurl=http%3A%2F%2Fwww.traffic.com%2FWashington-DC-Traffic%2FI-95_%28MD%29-2.html</feedburner:awareness><feedburner:origLink>http://www.traffic.com/Washington-DC-Traffic/I-95_(MD)-2.html</feedburner:origLink></item> <item> <title>RT-267 Dulles Toll Rd / Greenway EASTBOUND from RT-15/Leesburg Bypass to I-66: Jam Factor 0.5 - Wed, 13 Sep 2006 11:04:56 EDT</title> <description> RT-267 Dulles Toll Rd / Greenway EASTBOUND from RT-15/Leesburg Bypass to I-66: Jam Factor 0.5 - Incidents: 1 (Moderate) </description> <link>http://cityrss.traffic.com/feeds/rss_washingtondc?m=57</link> <pubDate>Wed, 13 Sep 2006 11:04:56 EDT</pubDate> <content:encoded><![CDATA[ <p><strong>RT-267 Dulles Toll Rd / Greenway EASTBOUND from RT-15/Leesburg Bypass to I-66</strong></p> <p><a href="http://www.traffic.com/Washington-DC-Traffic/RT-267_Dulles_Toll_Rd___Greenway-1.html"><img src="http://rss.traffic.com/images/jamFactors/jamFactor0.5.jpg" alt="jam factor" border="0" width="150" height="35" /></a><br /> - Jam Factor: 0.5<br /> - Incidents: 1 (Moderate) </p> <p><a href="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?a=9ISx12"><img src="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?i=9ISx12" border="0"></img></a></p> <div class="feedflare"><a href="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?a=T2Nrx7T8"><img src="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?i=T2Nrx7T8" border="0"></img></a></div><img src="http://cityrss.traffic.com/feeds/rss_washingtondc?g=57"/>]]></content:encoded> <feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=feeds/rss_washingtondc&itemurl=http%3A%2F%2Fwww.traffic.com%2FWashington-DC-Traffic%2FRT-267_Dulles_Toll_Rd___Greenway-1.html</feedburner:awareness><feedburner:origLink>http://www.traffic.com/Washington-DC-Traffic/RT-267_Dulles_Toll_Rd___Greenway-1.html</feedburner:origLink></item> <item> <title>DC-295 NORTHBOUND from I-295 to RT-295 Baltimore Washington Pkwy: Jam Factor 1.6 - Wed, 13 Sep 2006 11:04:56 EDT</title> <description> DC-295 NORTHBOUND from I-295 to RT-295 Baltimore Washington Pkwy: Jam Factor 1.6 - Incidents: 0 </description> <link>http://cityrss.traffic.com/feeds/rss_washingtondc?m=34</link> <pubDate>Wed, 13 Sep 2006 11:04:56 EDT</pubDate> <content:encoded><![CDATA[ <p><strong>DC-295 NORTHBOUND from I-295 to RT-295 Baltimore Washington Pkwy</strong></p> <p><a href="http://www.traffic.com/Washington-DC-Traffic/DC-295-1.html"><img src="http://rss.traffic.com/images/jamFactors/jamFactor1.6.jpg" alt="jam factor" border="0" width="150" height="35" /></a><br /> - Jam Factor: 1.6<br /> - Incidents: 0 </p> <p><a href="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?a=9IEyv8"><img src="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?i=9IEyv8" border="0"></img></a></p> <div class="feedflare"><a href="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?a=BOokjc86"><img src="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?i=BOokjc86" border="0"></img></a></div><img src="http://cityrss.traffic.com/feeds/rss_washingtondc?g=34"/>]]></content:encoded> <feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=feeds/rss_washingtondc&itemurl=http%3A%2F%2Fwww.traffic.com%2FWashington-DC-Traffic%2FDC-295-1.html</feedburner:awareness><feedburner:origLink>http://www.traffic.com/Washington-DC-Traffic/DC-295-1.html</feedburner:origLink></item> <item> <title>DC-295 SOUTHBOUND from RT-295 Baltimore Washington Pkwy to I-295: Jam Factor 0.1 - Wed, 13 Sep 2006 11:04:56 EDT</title> <description> DC-295 SOUTHBOUND from RT-295 Baltimore Washington Pkwy to I-295: Jam Factor 0.1 - Incidents: 0 </description> <link>http://cityrss.traffic.com/feeds/rss_washingtondc?m=35</link> <pubDate>Wed, 13 Sep 2006 11:04:56 EDT</pubDate> <content:encoded><![CDATA[ <p><strong>DC-295 SOUTHBOUND from RT-295 Baltimore Washington Pkwy to I-295</strong></p> <p><a href="http://www.traffic.com/Washington-DC-Traffic/DC-295-2.html"><img src="http://rss.traffic.com/images/jamFactors/jamFactor0.1.jpg" alt="jam factor" border="0" width="150" height="35" /></a><br /> - Jam Factor: 0.1<br /> - Incidents: 0 </p> <p><a href="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?a=eKEWrL"><img src="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?i=eKEWrL" border="0"></img></a></p> <div class="feedflare"><a href="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?a=oLGztp6P"><img src="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?i=oLGztp6P" border="0"></img></a></div><img src="http://cityrss.traffic.com/feeds/rss_washingtondc?g=35"/>]]></content:encoded> <feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=feeds/rss_washingtondc&itemurl=http%3A%2F%2Fwww.traffic.com%2FWashington-DC-Traffic%2FDC-295-2.html</feedburner:awareness><feedburner:origLink>http://www.traffic.com/Washington-DC-Traffic/DC-295-2.html</feedburner:origLink></item> <item> <title>I-295 NORTHBOUND from I-495 Capital Beltway (#1) to DC-295 Split: Jam Factor 0.4 - Wed, 13 Sep 2006 11:04:56 EDT</title> <description> I-295 NORTHBOUND from I-495 Capital Beltway (#1) to DC-295 Split: Jam Factor 0.4 - Incidents: 0 </description> <link>http://cityrss.traffic.com/feeds/rss_washingtondc?m=51</link> <pubDate>Wed, 13 Sep 2006 11:04:56 EDT</pubDate> <content:encoded><![CDATA[ <p><strong>I-295 NORTHBOUND from I-495 Capital Beltway (#1) to DC-295 Split</strong></p> <p><a href="http://www.traffic.com/Washington-DC-Traffic/I-295-1.html"><img src="http://rss.traffic.com/images/jamFactors/jamFactor0.4.jpg" alt="jam factor" border="0" width="150" height="35" /></a><br /> - Jam Factor: 0.4<br /> - Incidents: 0 </p> <p><a href="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?a=F1GoJt"><img src="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?i=F1GoJt" border="0"></img></a></p> <div class="feedflare"><a href="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?a=V1JrfiAh"><img src="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?i=V1JrfiAh" border="0"></img></a></div><img src="http://cityrss.traffic.com/feeds/rss_washingtondc?g=51"/>]]></content:encoded> <feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=feeds/rss_washingtondc&itemurl=http%3A%2F%2Fwww.traffic.com%2FWashington-DC-Traffic%2FI-295-1.html</feedburner:awareness><feedburner:origLink>http://www.traffic.com/Washington-DC-Traffic/I-295-1.html</feedburner:origLink></item> <item> <title>I-295 SOUTHBOUND from DC-295 Split to I-495 Capital Beltway (#1): Jam Factor 0.5 - Wed, 13 Sep 2006 11:04:56 EDT</title> <description> I-295 SOUTHBOUND from DC-295 Split to I-495 Capital Beltway (#1): Jam Factor 0.5 - Incidents: 0 </description> <link>http://cityrss.traffic.com/feeds/rss_washingtondc?m=45</link> <pubDate>Wed, 13 Sep 2006 11:04:56 EDT</pubDate> <content:encoded><![CDATA[ <p><strong>I-295 SOUTHBOUND from DC-295 Split to I-495 Capital Beltway (#1)</strong></p> <p><a href="http://www.traffic.com/Washington-DC-Traffic/I-295-2.html"><img src="http://rss.traffic.com/images/jamFactors/jamFactor0.5.jpg" alt="jam factor" border="0" width="150" height="35" /></a><br /> - Jam Factor: 0.5<br /> - Incidents: 0 </p> <p><a href="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?a=fO2Klt"><img src="http://cityrss.traffic.com/~a/feeds/rss_washingtondc?i=fO2Klt" border="0"></img></a></p> <div class="feedflare"><a href="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?a=USCEtlQX"><img src="http://cityrss.traffic.com/~f/feeds/rss_washingtondc?i=USCEtlQX" border="0"></img></a></div><img src="http://cityrss.traffic.com/feeds/rss_washingtondc?g=45"/>]]></content:encoded> <feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=feeds/rss_washingtondc&itemurl=http%3A%2F%2Fwww.traffic.com%2FWashington-DC-Traffic%2FI-295-2.html</feedburner:awareness><feedburner:origLink>http://www.traffic.com/Washington-DC-Traffic/I-295-2.html</feedburner:origLink></item> <feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feeds/rss_washingtondc</feedburner:awareness></channel> </rss> Link to comment Share on other sites More sharing options...
lod3n Posted September 14, 2006 Share Posted September 14, 2006 Cool. An RSS feed reader! Here, try this: #include <array.au3> InetGet("http://www.traffic.com/feeds/rss_washingtondc.xml", "C:\Program Files\Road Runner\Control\trdetails.txt", 1) $xml = fileread("C:\Program Files\Road runner\control\trdetails.txt") $aTitles = _SRE_Between($xml, "<title>", "</title>",1) ; the 1 makes it return an array of all matches _ArrayDisplay($aTitles,"Titles") Func _SRE_Between($s_String, $s_Start, $s_End, $i_ReturnArray = 0); $i_ReturnArray returns an array of all found if it = 1, otherwise default returns first found $a_Array = StringRegExp($s_String, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3) If Not @error And Not $i_ReturnArray And IsArray($a_Array) Then Return $a_Array[0] If IsArray($a_Array) Then Return $a_Array return $string EndFunc Also, mad props to whoever wrote _SRE_Between(). I picked it up in someone else's comment some time ago, and it's absolutely indispensable. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now