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
