SchweppesAle Posted May 5, 2009 Share Posted May 5, 2009 Hi, I'm looking to retrieve {subscriber_id} values from the following returned string. How would I go about doing this? Thanks <system> <status>success</status> <resultlist> <result id='Email Address'>{email_address}</result> <result id='Subscriber ID'>{subscriber_id}</result> </resultlist> <system> Quote Link to comment https://forums.phpfreaks.com/topic/156988-solved-string-tokenizer/ Share on other sites More sharing options...
ohdang888 Posted May 5, 2009 Share Posted May 5, 2009 can you wrap it around a <user_id> tag? if so, you can use simplexml_load_string Quote Link to comment https://forums.phpfreaks.com/topic/156988-solved-string-tokenizer/#findComment-826969 Share on other sites More sharing options...
SchweppesAle Posted May 5, 2009 Author Share Posted May 5, 2009 can you wrap it around a <user_id> tag? if so, you can use simplexml_load_string $xml = simplexml_load_string($response); echo $xml; doesn't seem to return anything. Maybe it's not in proper xml format? Quote Link to comment https://forums.phpfreaks.com/topic/156988-solved-string-tokenizer/#findComment-826981 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 What's $response? var_dump($response); ^ please. Quote Link to comment https://forums.phpfreaks.com/topic/156988-solved-string-tokenizer/#findComment-826985 Share on other sites More sharing options...
SchweppesAle Posted May 5, 2009 Author Share Posted May 5, 2009 it returns string(190) Quote Link to comment https://forums.phpfreaks.com/topic/156988-solved-string-tokenizer/#findComment-827006 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 So I'm guessing it's doing the right thing? You did get to see the output of the string right? Quote Link to comment https://forums.phpfreaks.com/topic/156988-solved-string-tokenizer/#findComment-827037 Share on other sites More sharing options...
kenrbnsn Posted May 5, 2009 Share Posted May 5, 2009 Here's an example: <?php $str = "<system> <status>success</status> <resultlist> <result id='Email Address'>{email_address}</result> <result id='Subscriber ID'>{subscriber_id}</result> </resultlist> </system>"; $xml = simplexml_load_string($str); echo '<pre>' . print_r($xml,true) . '</pre>'; echo $xml->resultlist->result[1]; ?> which outputs SimpleXMLElement Object ( [status] => success [resultlist] => SimpleXMLElement Object ( [result] => Array ( [0] => {email_address} [1] => {subscriber_id} ) ) ) {subscriber_id} Ken Quote Link to comment https://forums.phpfreaks.com/topic/156988-solved-string-tokenizer/#findComment-827062 Share on other sites More sharing options...
SchweppesAle Posted May 8, 2009 Author Share Posted May 8, 2009 Worked like a charm. Thanks again guys. Quote Link to comment https://forums.phpfreaks.com/topic/156988-solved-string-tokenizer/#findComment-829628 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.