z999 Posted November 2, 2006 Posted November 2, 2006 I'm writing a podcat downloader (name needed XD ). I have problems with reading the xml... I don't have Idea of how to do it. I have the _StrBetween (found here in the forum) function to do the actuall reading but I don't know how to convert it to variables. I don't have an idea for the algorithm itself... if you have any idea how to pass through the rows and identify each of them post it... I'm pretty stuck. the code for _StrBetween expandcollapse popup;================================================================================================== ; Function Name: _StrBetween($sString, $sStart, $sEnd, $vCase, $iSRE) ; ; Parameters: $sString: The string to search ; $sStart: The beginning of the string to find ; $sEnd: The end of the string to find ; $vCase: Case sensitive search: Default or -1 = Not case sensitive ; $iSRE: Choose whether to use StringRegExp or Regular Sting Manipulation to get the result ; Default or -1: Regular String Manipulation used (Non StringRegExp()) ; ; Description: Returns the string between the start search ($sStart) and the end search ($sEnd) ; ; Requirement(s) AuotIt Beta 3.2.1.8 or higher ; ; Return Value(s) On Success: A 0 based array [0] contains the first found string ; On Failure: @Error = 1: No inbetween string was found ; ; Author(s): SmOke_N ; Thanks to Valik for helping with the new StringRegExp (?s)(?i) isssue ;================================================================================================== Func _StrBetween($sString, $sStart, $sEnd, $vCase = -1, $iSRE = -1) If $iSRE = -1 Or $iSRE = Default Then If $vCase = -1 Or $vCase = Default Then $vCase = 0 If $vCase <> -1 And $vCase <> Default Then $vCase = 1 Local $sHold = '', $sSnSStart = '', $sSnSEnd = '' While StringLen($sString) > 0 $sSnSStart = StringInStr($sString, $sStart, $vCase) If Not $sSnSStart Then ExitLoop $sString = StringTrimLeft($sString, ($sSnSStart + StringLen($sStart)) - 1) $sSnSEnd = StringInStr($sString, $sEnd, $vCase) If Not $sSnSEnd Then ExitLoop $sHold &= StringLeft($sString, $sSnSEnd - 1) & Chr(1) $sString = StringTrimLeft($sString, $sSnSEnd) WEnd If Not $sHold Then Return SetError(1, 0, 0) $sHold = StringSplit(StringTrimRight($sHold, 1), Chr(1)) Local $aArray[UBound($sHold) - 1] For $iCC = 1 To UBound($sHold) - 1 $aArray[$iCC - 1] = $sHold[$iCC] Next Return $aArray Else If $vCase = Default Or $vCase = -1 Then $vCase = '(?i)' If $vCase <> Default And $vCase <> -1 Then $vCase = '' Local $aArray = StringRegExp($sString, '(?s)' & $vCase & $sStart & '(.*?)' & $sEnd, 3) If IsArray($aArray) Then Return $aArray Return SetError(1, 0, 0) EndIf EndFunc oÝ÷ Ù©Ý&Þ§x(}§îËb¢{hæ¶W¢±«¢+Ø)Õ¹Éáµ° ÀÌØíáµ±9µ¤íչѥ½¸Ñ¼ÉÑ¡a50Ѽ¥±($ÀÌØíÕÉɹÑa50õ¥±=Á¸ ÀÌØíáµ±9µ°À¤($ÀÌØíѽѱI½Ý9Õ´õ}¥± ½Õ¹Ñ1¥¹Ì¡MÉ¥ÁѥȵÀìÀÌØíáµ±9µ¤($ÀÌØíɽÝ9Õ´ôÄ(%½ÈÀÌØíɽÝ9Õ´Q¼ÀÌØíѽѱI½Ý9Õ´($$ÀÌØí±¥¹õ¥±I1¥¹ ÀÌØíÕÉɹÑa50°ÀÌØíɽÝ9Õ´¤($$íÁÕСÉͽµ¥Ìäí̹ѡ¸ÌäíÌѼÉÑ¡¥±=H¥¹ÑÑȵѡ½(
System Tester Posted November 3, 2006 Posted November 3, 2006 why aren't you helping??? please... Patience, Grasshopper. Try some of these - research the functions called in the help file, modity as you need to. HTH $SEARCH = FileFindFirstFile("c:\oasis\log\*.xml") ; Check if the search was successful If $SEARCH = -1 Then $FILENOTFOUND="TRUE" MsgBox(0,"file not found","NOT HERE!") Exit EndIf Dim $aRecords $FILE = FileFindNextFile($SEARCH) MsgBox(4096,"FILENAME", $file) If Not _FileReadToArray($FILE,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf ;read in each line....& blat it out to the screen. For $x = 1 to $aRecords[0] ToolTip($aRecords[$x],0,0) Next Results not guranteed. You use this at your own risk. I'm a noob. The AutoIt help file should be interrogated.The Editor should be SciTe.The forums should have been searched.
z999 Posted November 3, 2006 Author Posted November 3, 2006 my problem isn't opening the file or doing the actual reading. I need to recognize each line and then put it to the right variable. but because it's an RSS file it's even harder because the file has a header and then <item> <title>blabla</title> <anotherThing>blabla2</another thing> <withoutClosingTag type=1234 adress=http:\\www.blabla.com.blabla /> </item> and then it's repeating and I don't know how to identify the line... using a switch or IF's and THEN's its very messy
z999 Posted November 4, 2006 Author Posted November 4, 2006 i already tried _XMLDOMWrapper but he can't handle the multiple <item> tags. or i dont understand it right i asked for help about it but they didnt help me. plz help me i'm stuck and i dot want to make the function too much time consuming
Moderators SmOke_N Posted November 4, 2006 Moderators Posted November 4, 2006 i already tried _XMLDOMWrapper but he can't handle the multiple <item> tags. or i dont understand it right i asked for help about it but they didnt help me. plz help me i'm stuck and i dot want to make the function too much time consumingThe information (as stated) is already in a "Variable (array)" on the return for _StrBetween().So do you have a test file (source) and the "exact" information you are trying to obtain? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
z999 Posted November 5, 2006 Author Posted November 5, 2006 The information (as stated) is already in a "Variable (array)" on the return for _StrBetween().So do you have a test file (source) and the "exact" information you are trying to obtain? look at the way the file is built here it has 3 rows of version info then about 10-15 lines with specific tags to get and then... the repeating part. something that can be 2 or 100 <item> tags wich _XMLDOMWrapper can't handle (or I just didn't understood him.
Blast Posted November 15, 2006 Posted November 15, 2006 Could you please help me with understand to use _XMLDOMWrapper ?? I've read many topics about XMLDOMWrapper and didn't found information about difficult XPathes. I have this TAG: <svg xmlns="http://www.w3.org/2000/svg" xmlns:vnet="http://www.aveva.com/VNET" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 5942.000000 4202.000000" width="594.200009" height="420.200006"> ------------ SRC Code ------------------------------------------------------------------------ $oXML = _XMLFileOpen($fname) if @error or $oXML < 1 then MsgBox(0, '', "Can't open SVG") return endif $ncnt = _XMLGetNodeCount('svg[xmlns="http://www.w3.org/2000/svg"]') MsgBox(0, '', $ncnt) ------------ SRC Code ------------------------------------------------------------------------ My code doesn't work correctly. Variable $NCNT = -1 ?? How can i find it and get number of the children nodes? Thanks, Dmitry.1.svg.txt
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