Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
use simplexml_load_string then get error! Help..
Old 07-05-2010, 02:58 AM use simplexml_load_string then get error! Help..
Junior Talker

Posts: 1
Name: jammy
Trades: 0
Hi...

can any one help me plz...

i use simplexml_load_string then get error

Code:
Code:
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
my code below


Code:
<?
$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/>';
	}
?>
then i try to convert to utf-8 by code

Code:
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/>';
	}
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 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-06-2010, 05:53 PM Re: use simplexml_load_string then get error! Help..
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Nice job posting your code and giving it your best shot. You actually had the solution, but just got a little confused. Cleaned up a bit, you'll see that this gives you what you wanted:

PHP 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);

if ((
$parsed_xml simplexml_load_string($readydata)) === false) {
  echo 
'Error parsing XML file';
} else {
  foreach (
$parsed_xml->item as $item1) {
    echo 
$item1->hname.'<hr/>';
  }

__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to use simplexml_load_string then get error! Help..
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21833 seconds with 12 queries