simplexml-load-file

With simplexml_load_file I would like to differeniate between time out and and 404 errors

I am currently using: $page = simplexml_load_file('http://www.example.com/page.html'); In my code I would like to retry if the page time outs, but if the page is not found ( 404 ) I would like to add it to a list of not found pages. If I could differentiate between the two types of errors I can do the rest. Any help would be apprec...

PHP cURL multiple calls vs simplexml_load_file

If i am making multiple calls to an api on each page in a web app, is cURL right for me, or is using simplexml_load_file with the URL wrapper OK? Will opening, making the call, and closing the cURL connection multiple times negatively affect the app? ...

How do I load the contents of an rss feed rendered by php?

Wordpress is rendering an RSS feed at http://myurl.com/feed/rss/ but of course there's not actually a file there. I'm writing a script to read and render the RSS, but loading the "file" as XML fails, because there's not actually a file there. I write: $rss = simplexml_load_file('/news/feed/rss/'); And I get this error: Warning: simp...

php5 simple_xml_file parse error

Hello, I am trying to pass the XML code below, in the first instance using the php function simplexml_load_file. Currently the php code is incredibly simple as follows: if (file_exists('test.xml')) { $xml = simplexml_load_file('test.xml'); print_r($xml); } else { exit('Failed to open test.xml.'); } However on running th...

Use simplexml_load_file php funcion to load gmail feed

Hi all, I need to connect my php script to Gmail Atom feed to retrieve the count of unread messages, but I have problem on get the xml feed file: if($xmlGmailFeed = simplexml_load_file("https://USERNAME:[email protected]/gmail/feed/atom/")) $unreadMessages = $xmlGmailFeed->fullcount; gives: failed to load external entity ...

Simple XML parsing error

I'm trying to iterate through a Twitter XML File, where the container tag is <users>, and each user is <user>. I need to create a variable $id based on the XML attribute <id> for each user. Username is already instantiated. $url = "http://api.twitter.com/1/statuses/friends/$username.xml"; $xmlpure = file_get_contents($url); $listxml =...

php simplexml_load_file() with password protected url

Simple question for the one who knows the answer... $xml = simplexml_load_file("http://url/path/file.xml"); This url is .htaccess protected, how can I pass the login/password as arguments to the function? ...

Ideal way of dealing with Solr results in PHP?

Firslty, I'm aware of some similar questions along the lines of this one, but I think this situation is different enough to warrant its own question. I'm running a Solr index, through a jetty install on a LAMP server. I currently use the simplexml_load_file function to bring in the search results and then parse them trough a couple of f...

Getting cdata content while parsing xml file

I have an xml file <?xml version="1.0" encoding="utf-8"?> <xml> <events date="01-10-2009" color="0x99CC00" selected="true"> <event> <title>You can use HTML and CSS</title> <description><![CDATA[This is the description ]]></description> </event> </events> </xml> I used xpath and and xquer...

Is there anyway to make simpleXML work on web host.

<?php $twitter_url = 'http://twitter.com/statuses/user_timeline/ishrikrishna.xml?count=1'; $buffer = file_get_contents($twitter_url); $xml = new SimpleXMLElement($buffer); $status = $xml -> status; $tweet = $status -> text; echo $tweet; ?> I used this code to fetch tweets and it works successfully on localhost but not on my ...