BLACKISH DEV BLOG Support
 

 

Raw Data, XML and PHP

Tim Berners-Lee did a talk at TED about open, linked data, and even though the talk was a little weird, it was also sort of inspiring…
In short his point is this: Don’t just put your documents on the web, put your raw data on the web.

So for the next game I will release highscores-data as XML-files! (Of course I’ll also make a pretty website for all the people who don’t appreciate raw data as much as Tim Berners-Lee…) The cool thing about the highscores in XML is that everyone who’s willing can easily create his/her own highscores-site!

Now for the boring part:

The XML files are created with PHP5’s XMLWriter class. Since I couldn’t find a good enough example on how to use it, here’s one for you:


$writer = new XMLWriter();
$writer->openURI('myXmlFile.xml');
$writer->startDocument("1.0", "ISO-8859-1");
$writer->setIndent(true);

$writer->startElement("highscores");
$writer->startElement("record");
$writer->startElement("rank");
$writer->text("1");
$writer->endElement();
$writer->startElement("player");
$writer->text("Racer1");
$writer->endElement();
$writer->startElement("countrycode");
$writer->text("US");
$writer->endElement();
$writer->startElement("laptime");
$writer->text("26.42");
$writer->endElement();
$writer->endElement();
$writer->endElement();

$writer->endDocument();
$writer->flush();

This will result in XML-file like this.

I’ll post more info about where to access those files and how to use them once the game has launched…

Bookmark the permalink. Follow any comments here with the RSS feed for this post. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>