Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am making a call to some url : http://example.com/Service.asmx/getTodaysDiscussionForum which is xml data please see screenshot :enter image description here

$response = file_get_contents('http://103.1.115.87:100/Service.asmx/getTodaysDiscussionForum');

$response = new SimpleXMLElement($response);

print_r($response);exit;

it display following output :

SimpleXMLElement Object ( 
         [Table1] => Array ( [0] => SimpleXMLElement Object ( 
                                      [Id] => 1210 [Title] => Test Discussion, Dont Reply [CreatedDate] => 4/25/2014 10:42:49 AM 
                                      [Status] => Not Sent ) 
                             [1] => SimpleXMLElement Object ( 
                                      [Id] => 1182 [Title] => Negotiation Skills discussion [CreatedDate] => 4/25/2014 7:47:51 AM 
                                      [Status] => Not Sent )
                           )  
                        )

How can I store each data in a variables ?

I am new to this xml reading thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
241 views
Welcome To Ask or Share your Answers For Others

1 Answer

$xml = simplexml_load_string($xmlstring);
$json = json_encode($xml); 
$array = json_decode($json,TRUE);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...