How to parse UTF-16 XML received from API call

I am making an API call using PHP CURL to a specific URL. I am able to receive response in my browser.

CURL is saving this response in a Variable like this:

$output = curl_exec($ch); 

Now when I use

print_r(htmlspecialchars($output, true)); 

I get this response in my browser.

<?xml version="1.0" encoding="utf-16" standalone="no"?> <loginres> <sessiontoken>123456</sessiontoken> <timeout>7/30/2016 11:18:22 AM</timeout> <status>1</status> </loginres> 

Since, this is a UTF-16 encoded response, I am not able to use SimpleXML or DOM document. You can try this out(I have failed several times). Nothing is coming.

Also, I have tried, to use "explode" function with Array filter, and the response looks like this:

Array ( [0] =>  version="1.0" [2] => encoding="utf-16" [3] => standalone="no"?>   [5] => 123456  [7] => 7/30/2016 [8] => 11:26:09 [9] => AM  [11] => 1  ) 

Now, my question is , how do I use this file.... I wanted to create PHP variables out of XML tags, and parse them, to manipulate and save in my database.

The other option is to save the response in an xml file, in my local server, and use it using Jquery, Ajax, but I don't know how to do it. Please help.


Category: php Time: 2016-07-30 Views: 3

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.127 (s). 12 q(s)