SwiftlyTilting: usability, reusability

Sunday, October 31, 2004

SwiftXML: A PHP class for easy access to XML data

I put together a PHP class to accessing XML data recently. I’ve tried to make it as easy to use as possible, and I hope you find it useful. Here is a quick example of how to use SwiftXML to convert the SwiftlyTilting RSS feed into a web page:

<html>
<body>
<?
include_once('swiftxml.1.0.php');
$XML= swiftXML_use_file(’http://www.swiftlytilting.com/feed/rss2/’);

echo “<h1>”.$XML->get(”/channel/title”).”</h1>”;
echo “<h2>”.$XML->get(”/channel/description”).”</h2>”;

foreach ($XML->get(”//item”) as $item)
{	$url   = $item->get(”link”);
	$title = $item->get(”title”);
	$desc  = $item->get(”description”);

	echo html_entity_decode(”<h3><a href=”$url”>$title</a></h3>”
				. “<p>$desc</p>n”);
}

?>
</body>
</html>

See the output of this code.

Download the SwiftXML 1.0 Package.

Requires PHP 5.0 or higher


2 Comments

Good work Fitz, this could come in quite useful. :)

Comment by Damage — Sunday, October 31, 2004 @ 12:53 pm

i’m turning off comments for this post because it keeps getting hit with blog spam. Feel free to leave a comment on the SwiftXML v1.1 page.

Comment by swiftlytilting — Thursday, January 20, 2005 @ 11:53 am

Validate XHTML | Word Press