SwiftlyTilting: usability, reusability

Monday, November 1, 2004

SwiftXML v1.1 Released

I added a few things I meant to include in the initial release to make it easier to make XML documents from scratch. SwiftXML now has the ability to create empty XML documents, as well as the ability to add child blocks to them. Here is an example on how to create an RSS document:

<?
include_once('swiftxml.1.1.php');

$rss = swiftXML_create(”rss”);
$rss->setAttribute(”version”, “2.0″);

$channel = swiftXML_create(”channel”);
$channel->createChild(”title”,”Swiftly Tilting”);
$channel->createChild(”link”,”http://www.swiftlytilting.com”);

for($i = 0; $i < 10; $i++)
{	$item = swiftXML_create("item");
	$item->createChild(”title”,”title $i”);
	$item->createChild(”description”,”description $i”);
	$channel->createChild($item);
}

$rss->createChild($channel);

header(”Content-type: text/xml”);
echo $rss->asXML();

?>

See the output of above code.

Download the SwiftXML 1.1 package.


Comments Leave Comment | Comment RSS | TrackBack URL

No comments yet.

Leave a Comment

Validate XHTML | Word Press