 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Content with Style: Remove nodes in SimpleXMLElement
by Chris Cornutt July 16, 2009 @ 11:15:57
The Content with Style blog has this quick tip on removing nodes from inside of a SimpleXML object without causing problems with its internal handling.
You might think otherwise and hack it with unset(), as it was done in one of the web applications I inherited at work, but today I found out that this works under some conditions, but not with every setup. I'd love to tell you what exactly the differences are that make it break, but I didn't spend the time tracking it down.
Instead, he suggests a call to dom_import_simplexml to swap the object over to the DOM, performing a removeChild on the node and pushing it back over to SimpleXML if the need's there.
voice your opinion now!
removechild dom tutorial simplexml
TotalPHP.com: How to Read an RSS Feed with PHP 5
by Chris Cornutt April 22, 2009 @ 11:15:16
New on the TotalPHP blog today is this article talking about reading RSS feeds with PHP (more specifically with SimpleXML).
PHP 5's ability to read XML files is fantastically easy to use. In the past it was possible but it required quite a bit of long winded code to get any where. PHP 5's SimpleXmlElement function makes working with XML a breeze, and with much less code too!
They include a script as an example - five lines to completely parse and pull the title and link information out of the remote RSS file. The example creates a SimpleXML object using the feed's URL and makes each element inside accessible as an object (that can be looped through and properties can be checked on).
voice your opinion now!
title link object example simplexml php5 read rss
Nessa's Blog: Simple API Writing, Part I
by Chris Cornutt February 11, 2009 @ 12:08:11
Nessa has started off a series looking at writing your own API with part one posted recently focusing on the client-side first, writing an interface for their API.
Though in real applications you wouldn't need an API, all you'd need is a PHP script that accepts GET or POST input to perform some kind of action. In this example, we'll have a script that automatically adds DNS zones to a nameserver that runs cPanel as well. Most APIs do the same thing - you have a script, then that script accepts post/get variables, then does something.
Her example creates the request - a server, path, IP and hash key - and sends it off to the remote system. The result is pulled back in and parsed through a SimpleXML object. The credentials allow for access lists and a bit of security on the backend.
voice your opinion now!
api interface client use remote system hash ip simplexml cpanel
Fabien Potencier's Blog: Getting information from SVN with PHP
by Chris Cornutt February 05, 2009 @ 12:08:23
In a recent post Fabien Potencier took a look at one method for getting metadata information from a subversion repository about the project(s) inside.
Last year, I deployed a new tool to manage symfony plugins. The first goal of this tool was to simplify the process of contributing new plugins. [...] The question I wanted to answer was quite simple: How many plugins were created per month before and after the change?
He uses a very handy option to modify the output of an "svn log" command - the "--xml" argument. This outputs the latest information (like author, date, paths and msg) for each of the log entries. This can then be thrown into a call to simple_xml_load_file and parsed down into the numbers he was looking for. He even generated a graph of the results as they coordinated with the different symfony releases.
voice your opinion now!
subversion svn log xml output parse simplexml graph
Christoph Dorn's Blog: Your Mac can talk FeedBurner stats via PHP!
by Chris Cornutt September 18, 2008 @ 17:35:39
In a recent post to his blog Christoph Dorn shows off a cool little trick to getting your Mac to respond to your (vocal) request for website stats from FeedBurner.
You have a blog and you are proud of it. Your sense of self-worth depends on how many people are following it. Making a detour to FeedBurner every day (the feed stats only update once a day) to check on your vitals is simple and does not take long (with a bookmark) but there has to be a more automated way.
His better way involves tying together the speech recognition that OS X offers, the "say" command line tool and a PHP5 script that can go out and read/parse the FeedBurner XML information for your website. Throw in a little command line script and some set up in the Speech tools and you have a handy little script that can fetch your latest stat information just from your request.
voice your opinion now!
feedburner statistics mac osx php5 xml simplexml
Brian Moon's Blog: Stupid PHP Tricks Normalizing SimpleXML Data
by Chris Cornutt June 03, 2008 @ 09:34:22
Brian Moon has a "stupid PHP trick" posted to his blog today - normalizing SimpleXML data you've pulled in from just about any external source.
Anyhow, one annoying thing about SimpleXML has to do with caching. When using web services, we often cache the contents we get back. We were having a problem where we would get an error about a SimpleXML node not existing.
They were using memcache to store the information but came across problems when their code tried to use a (sometimes) empty tag. He gives two solutions - one using a recursive function that identifies the empty items and the other that encodes then decodes the object to and from JSON, keeping the values intact.
voice your opinion now!
trick stupid simplexml normalize json recursive empty tag
IBM developerWorks: Process and integrate Google Notebook data with PHP
by Chris Cornutt May 27, 2008 @ 12:05:23
A new tutorial over on the IBM developerWorks site (from Vikram Vaswani) shows how to pull data from the Google Notebook service into your script via the service's REST API.
Google Notebook is a free service that allows users to save and share notes and Web clippings in an online journal. A REST-based API allows developers to build customized PHP applications around this service using SimpleXML. In this article, you learn how to use the API, with examples of reading notebooks and notebook contents using PHP.
His method grabs the contents of the REST request and drops them into a SimpleXML object for easy manipulation. Different kinds of requests are included - getting the list of notebooks, getting the notebook's contents and how to add on extra parameters to the REST call to get more information in the responses.
voice your opinion now!
tutorial google notebook rest simplexml api
ThinkPHP Blog: Accessing Nike+ data with PHP
by Chris Cornutt May 15, 2008 @ 10:26:40
On the ThinkPHP blog today, Stephanie Ehrling has posted about a method for PHP to take in the output of the Nike+ equipment and put it into a usable form.
There is no official API that allows you to use the raw data. Nevertheless the data are sent to the Flash via XML so there is a chance to use them. For PHP Rasmus Lerdorf himself has implemented a class to access these data. The class allows to authenticate a user and fetch the running data of a user in a XML-Format
She gives an example of it in action - simple creation of an object then a call with the username and password. Behind the scenes, the data is pulled in and dropped into a SimpleXML object that includes total distance, total calories burned and data on the most recent run.
voice your opinion now!
nikeplus data xml simplexml class resmuslerdorf
|
Community Events
Don't see your event here? Let us know!
|