mercredi 9 mai 2018

How to convert the below mentioned xml data into json array in laravel

Find below the xml data:

<?xml version="1.0" encoding="utf-8"?> <interface-response> <Command>CHECK</Command> <APIType>API.NET</APIType> <Language>eng</Language> <ErrCount>1</ErrCount> <errors> <Err1>User not permitted from this IP address - 113.193.131.41. See http://enom.help/whitelist for details</Err1> </errors> <ResponseCount>1</ResponseCount> <responses> <response> <ResponseNumber>713254</ResponseNumber> <ResponseString>Policy error; unauthorized; user(s)</ResponseString> </response> </responses> <MinPeriod>1</MinPeriod> <MaxPeriod>10</MaxPeriod> <Server>sjl0vwapi08</Server> <Site>eNom</Site> <IsLockable>True</IsLockable> <IsRealTimeTLD>True</IsRealTimeTLD> <TimeDifference>+7.00</TimeDifference> <ExecTime>0.034</ExecTime> <Done>true</Done> <TrackingKey>5baa515b-8e29-4517-b879-05ae68e94f9a</TrackingKey> <RequestDateTime>5/9/2018 3:49:10 AM</RequestDateTime> <debug/> </interface-response>

I need to convert the above xml data to json array and pass it to view from the controller.

Find below the conrtroller code:

public function test()
{

    $response = Curl::to('https://reseller.enom.com/interface.asp?command=check&sld=decksys&tld=info&responsetype=xml&uid=decksys&pw=Amy.th3ist4917')->get();         


 $data = simplexml_load_string($response);

 $configdata   = json_encode($data);

 $value = json_decode($configdata, true);

 return view('clientlayout.main.test', array('response' =>$response));

 }

Find below the view code:



The route is given below:

Route::get('/test','EnomController@test');

suggest a solution solve this and print the data in my view page.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire