floodge Posted September 24, 2009 Share Posted September 24, 2009 -------------------------------------------------------------- <Entry1> <TS Value="1253666728883"/> <T Value="nothing usable in this box lololollol"/> <NT Value="541"/> <NS Value="0"/> <NC Value="196"/> <NP3 Value="WBP"/> <NP1 Value="Friendlyperson"/> <TT Value="-1"/> <PX Value="-1.0"/> <PY Value="-1.0"/> <PZ Value="-1.0"/> </Entry1> -------------------------------------------------------------- I have this above file and this code to grab from it $file = FileOpen("tester.xml", 0) $gui = FileRead($file) $entry = _StringBetween($gui,'<Entry1> ','</Entry1>') The problem is, $entry is ALWAYS equal to zero no matter what I tweak - It's pretty late but I have no idea why this is the case Link to comment Share on other sites More sharing options...
jvanegmond Posted September 24, 2009 Share Posted September 24, 2009 Here it is: $entry = _StringBetween($gui,'<Entry1> ','</Entry1>') ; Right about . . . . . . . . . . . . ^ there github.com/jvanegmond Link to comment Share on other sites More sharing options...
floodge Posted September 24, 2009 Author Share Posted September 24, 2009 Here it is: $entry = _StringBetween($gui,'<Entry1> ','</Entry1>') ; Right about . . . . . . . . . . . . ^ there Nope, still fails just the same without that - in fact i added it to try and trick it into working Link to comment Share on other sites More sharing options...
99ojo Posted September 24, 2009 Share Posted September 24, 2009 -------------------------------------------------------------- <Entry1> <TS Value="1253666728883"/> <T Value="nothing usable in this box lololollol"/> <NT Value="541"/> <NS Value="0"/> <NC Value="196"/> <NP3 Value="WBP"/> <NP1 Value="Friendlyperson"/> <TT Value="-1"/> <PX Value="-1.0"/> <PY Value="-1.0"/> <PZ Value="-1.0"/> </Entry1> -------------------------------------------------------------- I have this above file and this code to grab from it $file = FileOpen("tester.xml", 0) $gui = FileRead($file) $entry = _StringBetween($gui,'<Entry1> ','</Entry1>') The problem is, $entry is ALWAYS equal to zero no matter what I tweak - It's pretty late but I have no idea why this is the case Hi, i'm having the same problem and didn't find a solution with _StringBetween. If your xml file always look like above, i would do it like this: $file = FileOpen("c:\temp\test.xml", 0) $text = FileRead($file) FileClose ($file) $entry = StringTrimRight (StringTrimLeft ($text,9), 11) MsgBox (0,"",$entry) Link to comment Share on other sites More sharing options...
floodge Posted September 24, 2009 Author Share Posted September 24, 2009 I knew it wasn't just me! I'll try and substitute your alternate way Link to comment Share on other sites More sharing options...
Malkey Posted September 24, 2009 Share Posted September 24, 2009 Here are a couple of ways. ; ;==== This way ======================================================== #include <string.au3> $file = "test.xml" $text = FileRead($file) ConsoleWrite($text & @CRLF) $entry = _StringBetween($text, "<Entry1>" & @CRLF, @CRLF & "</Entry1>") MsgBox(0, "_StringBetween Result", $entry[0]) ;======================================================================= ; Or this way ;======================================================================= $text = FileRead("test.xml") $entry = StringRegExpReplace($text, "(?:<Entry1>\v+)(?s)(.*?)(\v+</Entry1>)", "\1") MsgBox(0, "StringRegExpReplace Result", $entry) ;======================================================================= ; Link to comment Share on other sites More sharing options...
99ojo Posted September 24, 2009 Share Posted September 24, 2009 (edited) Here are a couple of ways. ; ;==== This way ======================================================== #include <string.au3> $file = "test.xml" $text = FileRead($file) ConsoleWrite($text & @CRLF) $entry = _StringBetween($text, "<Entry1>" & @CRLF, @CRLF & "</Entry1>") MsgBox(0, "_StringBetween Result", $entry[0]) ;======================================================================= ; Or this way ;======================================================================= $text = FileRead("test.xml") $entry = StringRegExpReplace($text, "(?:<Entry1>\v+)(?s)(.*?)(\v+</Entry1>)", "\1") MsgBox(0, "StringRegExpReplace Result", $entry) ;======================================================================= ; Hi, thanks for opening eyes. I should have read helpfile better. Such a shame Success: A 0 based $array[0] contains the first found string. ;-)) Stefan Edited September 24, 2009 by 99ojo Link to comment Share on other sites More sharing options...
jvanegmond Posted September 24, 2009 Share Posted September 24, 2009 Nope, still fails just the same without that - in fact i added it to try and trick it into workingPlease try the files I have attached. You'll find that the space was the error. github.com/jvanegmond Link to comment Share on other sites More sharing options...
99ojo Posted September 24, 2009 Share Posted September 24, 2009 (edited) Please try the files I have attached. You'll find that the space was the error. Hi, i think he did the same mistake as me: Msgbox (0,"",$entry) instead of Msgbox (0,"",$entry [0]) ;-)) Stefan Edited September 24, 2009 by 99ojo Link to comment Share on other sites More sharing options...
jvanegmond Posted September 24, 2009 Share Posted September 24, 2009 No, displaying an array as string always returns "". He says $entry is equal to 0, which is not "", but instead is the error value as returned by _StringBetween. That's not his mistake. github.com/jvanegmond Link to comment Share on other sites More sharing options...
99ojo Posted September 24, 2009 Share Posted September 24, 2009 (edited) Nope, still fails just the same without that - in fact i added it to try and trick it into working@ManadarLook at this answer from him, just after your tip with the blank. So i think, he means "" and not 0.But in fact, your right if $entry would be really zero, _StringBetween failed. :-)))Stefan Edited September 24, 2009 by 99ojo Link to comment Share on other sites More sharing options...
jvanegmond Posted September 24, 2009 Share Posted September 24, 2009 There's really no point in arguing over what we interpreted what he said. He said the result was zero, he never said otherwise. github.com/jvanegmond 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