par
RekinMalad » 31 août 2007, 22:27
Bonjour à tous.
Pour interpreter les commandes coté PHP d'un XMLSocket, j'avais pondu ce script:
<?php
$command = '<test machin="cool" machine="pascool">Trux</test>';
$str = <<<XML
$command
XML;
$commande = Array();
$to_command = explode("<", $command);
$to_command = explode(" ", $to_command[1]);
$commande['name'] = $to_command[0];
echo $commande['name'];
$xml = simplexml_load_string($str);
foreach($xml->test[0]->attributes() as $a => $b) {
$commande[$a] = $b;
}
$commande['value'] = $xml->test;
echo "<pre>";
printf($commande);
// je ne me souviens plus si c'est printf ou printr qui affiche joliement les array
echo "</pre>";
?>
Et la, ce bougre me sort:
Fatal error: Call to undefined function: simplexml_load_string() in c:\program files\easyphp1-8\www\tests.php on line 11
On m'a dit qu'il fallait inclure ma classe et l'initialiser, mais je ne sais pas du tout comment faire ...
... je m'étais aidé de
ces pages pour pondre ce script...
Si on pouvait m'aider, ca serait sympa
Merci d'avance ... !
Bonjour à tous.
Pour interpreter les commandes coté PHP d'un XMLSocket, j'avais pondu ce script:
[php]<?php
$command = '<test machin="cool" machine="pascool">Trux</test>';
$str = <<<XML
$command
XML;
$commande = Array();
$to_command = explode("<", $command);
$to_command = explode(" ", $to_command[1]);
$commande['name'] = $to_command[0];
echo $commande['name'];
$xml = simplexml_load_string($str);
foreach($xml->test[0]->attributes() as $a => $b) {
$commande[$a] = $b;
}
$commande['value'] = $xml->test;
echo "<pre>";
printf($commande);
// je ne me souviens plus si c'est printf ou printr qui affiche joliement les array
echo "</pre>";
?>[/php]
Et la, ce bougre me sort:
Fatal error: Call to undefined function: simplexml_load_string() in c:\program files\easyphp1-8\www\tests.php on line 11
On m'a dit qu'il fallait inclure ma classe et l'initialiser, mais je ne sais pas du tout comment faire ...
... je m'étais aidé de [url=http://www.journaldunet.com/developpeur/tutoriel/php/040921-php-seguy-simplexml-1a.shtml]ces pages[/url] pour pondre ce script...
Si on pouvait m'aider, ca serait sympa :(
Merci d'avance ... !