[ create a new paste ] login | about

Link: http://codepad.org/5i75PoAm    [ raw code | output | fork ]

PHP, pasted on Feb 14:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php $string = '<?xml version="1.0" encoding="utf-16"?>
<Response Version="1.0">
   <DateTime>2/13/2013 10:37:24 PM</DateTime>
   <Contact_ID>151-233-DD</Contact_ID>
   <Quote_ID>ojc332-ewied-23e3ed</Quote_ID>
   <Status>Failure</Status>
   <Reason>Incorrect Contact ID</Reason>
</Response>'
; 
                                                                        
                                           
$xml = simplexml_load_string(preg_replace('/(<\?xml[^?]+?)utf-16/i', '$1utf-8', $string)); 
echo "<pre>";print_r($xml); 
?>


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
<pre>SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [Version] => 1.0
        )

    [DateTime] => 2/13/2013 10:37:24 PM
    [Contact_ID] => 151-233-DD
    [Quote_ID] => ojc332-ewied-23e3ed
    [Status] => Failure
    [Reason] => Incorrect Contact ID
)


Create a new paste based on this one


Comments: