XML Content einbauen?
Posted: Sat Jul 26, 2008 10:47 am
Hi Mädels und Jungs!
Gibt es eine Möglichkeit in der Seitenleite XML-Content einzubauen?
Gibt es eine Möglichkeit in der Seitenleite XML-Content einzubauen?
Code: Select all
Unter http://magic-volker.myminicity.com/xml kommt dieses Ergebnis:
<?xml version="1.0" encoding="UTF-8" ?>
- <city>
<host>magic-volker.myminicity.com</host>
<name>Magic Volker</name>
<region code="DE">germany</region>
<ranking>4676</ranking>
<population>263</population>
<incomes>57450</incomes>
<unemployment>0</unemployment>
<transport>100</transport>
<criminality>0</criminality>
<pollution>0</pollution>
<nextnuke>1</nextnuke>
<signatures>0</signatures>
<bases com="0" env="0" ind="72" sec="0" tra="33" />
</city>
Code: Select all
<?php
class serendipity_plugin_xmlout extends serendipity_plugin {
var $title = 'XML Output';
function introspect(&$propbag) {
global $serendipity;
$propbag->add('name', 'My Minicity');
$propbag->add('description', '');
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '1.0');
}
function generate_content(&$title) {
$title = $this->title;
$xml = simplexml_load_string(file_get_contents('http://magic-volker.myminicity.com/xml'));
echo "Meine Stadt hat " . $xml->population . " Einwohner. Tschö!";
}
}
Code: Select all
<?php
class serendipity_plugin_xmlout extends serendipity_plugin {
var $title = 'XML Output';
function introspect(&$propbag) {
global $serendipity;
$propbag->add('name', 'My Minicity');
$propbag->add('description', '');
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '1.0');
}
function generate_content(&$title) {
global $serendipity;
$title = $this->title;
$cachefile = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE . '/xmlout.dat';
if (!file_exists($cachefile) || filemtime($cachefile) < (time()-1440)) {
// Cache alle 1440 Sekunden neu schreiben
$xml = simplexml_load_string(file_get_contents('http://magic-volker.myminicity.com/xml'));
$out = "Meine Stadt hat " . $xml->population . " Einwohner. Tschö!";
$fp = fopen($cachefile, 'w');
fwrite($fp, $out);
fclose($fp);
} else {
$out = file_get_contents($cachefile);
}
}
}
Code: Select all
Fatal error: Call to undefined function: simplexml_load_string() in /var/www/web443/html/inhalte/01-blog/plugins/serendipity_plugin_xmlout/serendipity_plugin_xmlout.php on line 19
Code: Select all
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /var/www/web443/html/inhalte/01-blog/plugins/serendipity_plugin_xmlout/serendipity_plugin_xmlout.php on line 19
Warning: file_get_contents(http://magic-volker.myminicity.com/xml) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /var/www/web443/html/inhalte/01-blog/plugins/serendipity_plugin_xmlout/serendipity_plugin_xmlout.php on line 19