use simplexml_load_string then get error! Help..

Discussion in 'PHP' started by jam2525, Jul 4, 2010.

  1. #1
    Hi...

    can any one help me plz...

    i use simplexml_load_string then get error

    Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Unsupported encoding windows-874 in
    
    Warning: simplexml_load_string() [function.simplexml-load-string]: <?xml version="1.0" encoding="windows-874"?> in
    
    Code (markup):
    my code below

    <?
    $xml  = "http://www.ido24.com/xml_code_hotel_full_request.php?p=108trip.com&d=rayong&c=USD&l=en&s=r";
    
    	$session = curl_init($xml);
    	curl_setopt($session, CURLOPT_HEADER, false);
    	curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    	$response = curl_exec($session);
    	curl_close($session);
    	$parsed_xml = simplexml_load_string($response);
    
     foreach ($parsed_xml->item as $item1)
     	{
    	echo $item1->hname.'<hr/>';
    	}
    ?>
    Code (markup):

    then i try to convert to utf-8 by code

    $rawdata = file_get_contents("http://www.ido24.com/xml_code_hotel_full_request.php?p=108trip.com&d=rayong&c=USD&l=en&s=r");
    
    $readydata = iconv('windows-874' , 'utf-8' , $rawdata);
    
    	$session = curl_init($readydata);
    	curl_setopt($session, CURLOPT_HEADER, false);
    	curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    	$response = curl_exec($session);
    	curl_close($session);
    	$parsed_xml = simplexml_load_string($response);
    	
    
    
     foreach ($parsed_xml->item as $item1)
     	{
    	echo $item1->hname.'<hr/>';
    	}
    Code (markup):
    it's nothing display

    can anyone help me please ...

    i run on hosting linux godaddy.com but i run other hosting (in thailand) it's worked.

    Thank...

    jam
     
    jam2525, Jul 4, 2010 IP
  2. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #2
    Well this is not the way it should be done, but try to
    
    $xml  = "http://www.ido24.com/xml_code_hotel_full_request.php?p=108trip.com&d=rayong&c=USD&l=en&s=r";
    $session = curl_init($xml);
    curl_setopt($session, CURLOPT_HEADER, false);
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($session);
    curl_close($session);
    $response = str_replace('windows-874','utf-8',$response);
    $parsed_xml = simplexml_load_string($response);
    
    PHP:
     
    AsHinE, Jul 5, 2010 IP
  3. happilyadi

    happilyadi Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,
    I have a sitemap generator script for windows hosting. If youwant PM me your mail i'll conatct you personally.
     
    happilyadi, Jul 5, 2010 IP
  4. jam2525

    jam2525 Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4

    thank you AsHinE it worked.

    thank you very much.
     
    jam2525, Jul 5, 2010 IP