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
XML parsing error in Safari
Old 10-13-2008, 08:23 PM XML parsing error in Safari
Rusalka's Avatar
Experienced Talker

Posts: 36
Name: Greta
Location: Winchestertonfieldville
Trades: 0
I'm grabbing an xml doc from the web, picking it apart and spitting it out in my own site. It works great in IE and FF, but for some reason it's throwing me an error in Safari...

Here's the error:
A PHP Error was encountered

Severity: Warning
Message: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 2209: parser error : Start tag expected, '<' not found
Filename: libraries/thingy.php
Line Number: 30

Here's the code:

PHP Code:
function HTTPRequest($url)
    {
  
$ch curl_init(); 
    
curl_setopt($ch,CURLOPT_URL,$url); 
    
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
    
//curl_setopt($ch,CURLOPT_MUTE,1); 
    
curl_setopt($ch,CURLOPT_USERAGENT,$_SERVER["HTTP_USER_AGENT"]); 
    
curl_setopt($chCURLOPT_TIMEOUT10); //times out after 10 
    
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1); 
    
$data curl_exec ($ch); 
    
curl_close ($ch); 
    return 
$data
    }
 
 function 
GetXML()
 {
 
  
$xmlID $this->HTTPRequest("some.xml");
  
$xml = new SimpleXMLElement($xmlID);  //  <--- line 30
 
  
return $xml;
 } 
Anyone know why Safari is bugging out?

Last edited by Rusalka; 10-13-2008 at 08:25 PM..
Rusalka is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-14-2008, 03:02 AM Re: XML parsing error in Safari
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
The xml is malformed, as the error message tells you:
Quote:
Start tag expected, '<' not found
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 10-14-2008, 03:33 AM Re: XML parsing error in Safari
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
OMG

PHP Code:
curl_setopt($ch,CURLOPT_USERAGENT$_SERVER["HTTP_USER_AGENT"]); 
The problem is definitely here.

To debug this issue write the result of $this->HTTPRequest somewhere and ensure that you didn't receive some sht instead of required data. It seems like for some reason the source sends sht to safari. Try to always use user-agent that works if this is not a critical requirement.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to XML parsing error in Safari
 

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.14743 seconds with 12 queries