Php Parser Error Document Is Empty In
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site
1 Parser Error Document Is Empty
About Us Learn more about Stack Overflow the company Business Learn more about :1: parser error : document is empty libreoffice hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join simplexml_load_string the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up simplexml_load_file Document is empty
Simplexml_load_file
up vote 2 down vote favorite I'm pulling from a RSS feed: http://search.library.utoronto.ca/UTL/index?Ntt=starcraft&Ntk=Anywhere&Ntx=mode+matchallpartial&N=0&Nu=p_work_normalized&Np=1&rss=1 If you navigate to that with a browser, you get a nice xml page. However, if I do simplexml_load_file("the above url"); in php, I get 1: parser error : Document is empty 1: parser error : Start tag expected, '<' not found in my_file So why can the browser get it but
Xml Validator
not PHP? If I do file_get_contents("the above url") the function fails with FALSE returned. php xml-parsing simplexml share|improve this question edited Oct 18 '12 at 15:07 Florent 8,26762543 asked Oct 18 '12 at 15:05 Sean Xiao 4511816 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted The site is blocking requests from PHP. First run
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us php try catch Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up simplexml_load_file problems while browsing securely up vote http://stackoverflow.com/questions/12957779/simplexml-load-file-document-is-empty 0 down vote favorite I'm getting a lot of errors when I browse a clients site securely that have to do with the simplexml_load_file function. Here's an example: Warning: simplexml_load_file() [function.simplexml-load-file]: https://xxxxxxxx/settings.xml:1: parser error : Document is empty in /xx/xx/xx/xx/xx/ on line 0 The site is on a dedicated server from SingleHop. It only happens when I browse the site with https://, and works fine http://stackoverflow.com/questions/6638486/simplexml-load-file-problems-while-browsing-securely when browsed with http://. Seems to be loading the XML file just fine with https:// as well: https://consumerstrust.org/wp-content/plugins/easyfanpagedesign/framework/settings.xml The XML is parsed from a class: public function efpd_load_settings($xmlfile){ $xmlparse=simplexml_load_file($xmlfile); $settings=array(); $setint=0; foreach($xmlparse->option as $xml){ $option[$setint]=(array)$xml; array_push($settings,$option[$setint]); $setint++; } return $settings; } and ran like this: $efpdxml=plugins_url('settings.xml',__FILE__); // plugins_url() is a WP function - returns the value just fine. $efpdsettings=Efpd::efpd_load_settings($efpdxml); Is this something that happens commonly? Also anything to fix it? If you need any more info to help me solve this just let me know and I will provide it. Thanks. php xml simplexml share|improve this question edited Jun 24 '13 at 1:16 hakre 134k26216390 asked Jul 10 '11 at 0:56 Jared 66931230 have you tried to cURL request the file to your server? –brady.vitrano Jul 10 '11 at 1:01 1 The error seems to indicate that the document is empty (as it doesn't have any child nodes). Can you access it in your browser using https and confirm that you can see the XML? –Francois Deschenes Jul 10 '11 at 1:01 @brady.vitrano - I'm not quite sure how to do that to be honest :( -- @Francois Deschenes - I accessed the X
and Objects Namespaces Errors Exceptions Generators References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Context options and parameters Supported Protocols and Wrappers Security Introduction General considerations Installed as http://php.net/manual/en/simplexml.examples-errors.php CGI binary Installed as an Apache module Session Security Filesystem Security Database http://www.sitepoint.com/forums/showthread.php?612853-SimpleXML-errors Security Error Reporting Using Register Globals User Submitted Data Magic Quotes Hiding PHP Keeping Current Features HTTP authentication with PHP Cookies Sessions Dealing with XForms Handling file uploads Using remote files Connection handling Persistent Database Connections Safe Mode Command line usage Garbage Collection DTrace Dynamic Tracing Function parser error Reference Affecting PHP's Behaviour Audio Formats Manipulation Authentication Services Command Line Specific Extensions Compression and Archive Extensions Credit Card Processing Cryptography Extensions Database Extensions Date and Time Related Extensions File System Related Extensions Human Language and Character Encoding Support Image Processing and Generation Mail Related Extensions Mathematical Extensions Non-Text MIME Output Process Control Extensions Other Basic Extensions Other Services Search document is empty Engine Extensions Server Specific Extensions Session Extensions Text Processing Variable and Type Related Extensions Web Services Windows Only Extensions XML Manipulation GUI Extensions Keyboard Shortcuts? This help j Next menu item k Previous menu item g p Previous man page g n Next man page G Scroll to bottom g g Scroll to top g h Goto homepage g s Goto search(current page) / Focus search box SimpleXMLElement » « Basic SimpleXML usage PHP Manual Function Reference XML Manipulation SimpleXML Examples Change language: English Brazilian Portuguese Chinese (Simplified) French German Japanese Korean Romanian Russian Spanish Turkish Other Edit Report a Bug Dealing with XML errors Dealing with XML errors when loading documents is a very simple task. Using the libxml functionality it is possible to suppress all XML errors when loading the document and then iterate over the errors. The libXMLError object, returned by libxml_get_errors(), contains several properties including the message, line and column (position) of the error. Example #1 Loading broken XML string libxml_use_internal_errors(true $xmlstr=simplexml_load_file('http://feeds.feedburner.com/BloggerFCO');
The above code results in the following errors: Code: Warning: simplexml_load_file() [function.simplexml-load-file]: http://feeds.feedburner.com/BloggerFCO:1: parser error : Document is empty in /home/civicsur/public_html/local/task/test/feedtest.php on line 3 Warning: simplexml_load_file() [function.simplexml-load-file]: in /home/civicsur/public_html/local/task/test/feedtest.php on line 3 Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/civicsur/public_html/local/task/test/feedtest.php on line 3 Warning: simplexml_load_file() [function.