TheMadScientist

msg:4009878 | 6:54 am on Oct 20, 2009 (gmt 0) |
How about: if(preg_match("/<result>([0-9]+)<\/result>/",$xml_repsonse,$store_number)) { $the_id_number=$store_number[1]; // The rest of your code here. } else { echo $error="There was no number between <result> & </result>"; }
|
kieranmullen

msg:4010135 | 3:51 pm on Oct 20, 2009 (gmt 0) |
But the sucessful response does not have the word result in it. Why use the word result? thanks
|
TheMadScientist

msg:4010340 | 9:09 pm on Oct 20, 2009 (gmt 0) |
Uh, I was going by what you posted as the successful response? What I posted matches <result>ANYNUMBER</result> I used a regular expression to do what you were doing with the code below, without pulling the code apart... (I'm really not sure if I understand your question or not.) list($a,$b)=split("<result>",$full_arr['response'][$key],2); list($c,$d)=split("</result>",$b,2); if ($c==1) {$succ="SUCCESS"; $no_of_succ++;} else $succ="FAILED"; This would match only <result>0</result> or <result>1</result> if(preg_match("/<result>([0-1]{1})<\/result>/",$xml_repsonse,$store_number)) { $the_id_number=$store_number[1]; // The rest of your code here. } else { echo $error="There was no number between <result> & </result>"; } I just expanded it to match any number between the <result> tags. If you need the tags stored, use something like: preg_match("/(<result>([0-9]+)<\/result>)/",$xml_repsonse,$store_number)); if($store_number[2]!='') { $the_id_number=$store_number[2]; echo "There was a number between <result> & </result> the full string is:<br />"; echo $store_number[1]; // The rest of your code here. } else { echo $error="There was no number between <result> & </result>"; }
|
kieranmullen

msg:4010386 | 10:26 pm on Oct 20, 2009 (gmt 0) |
The code I posted already worked based on parsing the text between the word "response". However the sucessful response now is ID: # (where # is the id of the message) and error is Err: 601 So perhaps just an updated string that searches for the begining of the string to be ID: if not error.
|
TheMadScientist

msg:4010437 | 11:46 pm on Oct 20, 2009 (gmt 0) |
| The code I posted already worked based on parsing the text between the word "response". However the sucessful response now is ID: # (where # is the id of the message) |
| I'm not sure about the error number, but it seems to me you will need to match and store the value (or at least check for a numerical match) between the response tags... What I posted does that. I'll leave it to you or someone else who has a better idea than I do. Maybe intval() will help you out, because it seems you are checking for 1 or 0 and not 'any number except 0' as you will need to do (IMO) to ensure an accurate match... I'll leave it to you and others from here. Sorry I couldn't be of more help.
|
kieranmullen

msg:4010450 | 11:58 pm on Oct 20, 2009 (gmt 0) |
I do not need to match the response tags. that was the old sucess response... now I just get ID: I do not care abotu the error number Basically look for begining string ID: = sucess if it is something else then error
|
TheMadScientist

msg:4010461 | 12:09 am on Oct 21, 2009 (gmt 0) |
I have no clue what you're asking for if you're posting old code, rather than what you're actually looking for a response in... How do you get the ID? Is it just the number? No one can really answer when they don't know what you're getting now and need to check for a match of some type. Like I said, I'm clueless as to what you're looking for and apparently all you've posted is the old code without posting what you're actually searching through to find the ID now. Are you even searching anything? Do you mean you get ID: NUMBER? Then just modify my regular expression: if(preg_match("/^ID:\s?[0-9]+$/"),$what_ever_variable_you_are_using) { echo "There's a number here."; }
|
eeek

msg:4010462 | 12:13 am on Oct 21, 2009 (gmt 0) |
Have you considered using simplexml and actually parsing the result?
|
|