DCCD Posted January 22, 2015 Share Posted January 22, 2015 Hi, i need help here's a xml file i need to check some data in the xml file but the second StringRegExp return 0 why? Here's the XML file <entry xmlns="http://www.w3.org/2005/Atom"> <id>885454</id> <published>2013-11-10T21:53:00.001+02:00</published> <updated>2015-01-11T05:13:52.877+02:00</updated> <category scheme="kind" term="post" /> <title type="text">TITLE</title> <content type="html" /> <link rel="replies" type="application/atom+xml" href="/comments/default" title="Post Comments" /> <link rel="replies" type="text/html" href="/comment-form" title="0 Comments" /> <link rel="edit" type="application/atom+xml" href="/" /> <link rel="self" type="application/atom+xml" href="/" /> <link rel="alternate" type="text/html" href="/" title="TITLE" /> <thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total> </entry> Autoit Script $XML = FileRead(@ScriptDir & '\default.xml') Local $nOffset = 1 Local $aArray While 1 $aArray = StringRegExp($XML, '(?s)<entry[^>]*>.*?</entry>', 1, $nOffset) If @error = 0 Then $nOffset = @extended Else ExitLoop EndIf For $i = 0 To UBound($aArray) - 1 ;ConsoleWrite($aArray[$i]) ConsoleWrite(StringRegExp($aArray[$i], '(?i)<published>(.*?)</published>', 1, $nOffset)); return 0! Next WEnd Any help would be greatly appreciated . [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
Solution jguinch Posted January 22, 2015 Solution Share Posted January 22, 2015 (edited) The last StringRegExp should return an array, not a string. You should use ConsoleWrite(StringRegExp($aArray[$i], '(?i)<published>(.*?)</published>', 1, $nOffset)[0]) instead, but in your case, $nOffset is out of range. I don't really understand why you want to use $nOffset for, but maybe this code would match with your need : Local $XML = FileRead(@ScriptDir & '\default.xml') Local $aArray = StringRegExp($XML, '(?s)<entry[^>]*>.*?</entry>', 3) If NOT @error Then For $i = 0 To UBound($aArray) - 1 $aPublisher = StringRegExp($aArray[$i], '(?i)<published>(.*?)</published>', 1) ConsoleWrite ( $aPublisher[0] ) Next EndIf Edited January 22, 2015 by jguinch DCCD 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 22, 2015 Moderators Share Posted January 22, 2015 (edited) From your example, it's going to fail for us, you only provided 1 entry. The return is the number of characters, then you ask it to search from that return on. Anyway.... The first regex works for me when I double your xml example. The ConsoleWrite(StringRegExp()) ... You know that it returns an array right? Offset doesn't apply to that for/loop because you're accessing the data directly from the array. So this should work if you're validating only: ConsoleWrite(StringRegExp($aArray[$i], '(?i)<published>(.*?)</published>', 0) & @CRLF) Edited January 22, 2015 by SmOke_N Iterated validation DCCD 1 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. Link to comment Share on other sites More sharing options...
DCCD Posted January 22, 2015 Author Share Posted January 22, 2015 jguinch & SmOke_N, i really appreciate your help thank you very much to both of you [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 22, 2015 Moderators Share Posted January 22, 2015 Out of curiosity, do the xml udf's from the forum not meet your needs? 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. Link to comment Share on other sites More sharing options...
DCCD Posted January 22, 2015 Author Share Posted January 22, 2015 i don't know about xml udf!, i was using Autoit help file to find some func/example. [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 22, 2015 Moderators Share Posted January 22, 2015 Here is a bunch of links to it/them? DCCD 1 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. 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