bonjour, voila j'utilise SimpleXML pour récupéré des donnée dans des fichier qui me font office un peut de "base de donnée" mais j'ai un bug quan j'essai d'extraire une donnée, voirci le code, l'erreur, et le fichier
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <?php
require "serverinfo.php";
$account = $_POST['account'];
$password = $_POST['password'];
$accountxml = $account . ".xml";
$fileaccountdir = $accountdir . $accountxml; // $accountdir est une variable dans serverinfo.php qui définit le chemin complet pour accédé au dossier contenant tout les account
if ($account && $password != null)
{
if (file_exists($fileaccountdir)) {
$fileaccount = simplexml_load_file($fileaccountdir);
echo $fileaccount->account[0]['pass'];
var_dump($fileaccount);
} else {
echo $fileaccountdir . '<BR>';
exit('Echec lors de l\'ouverture du fichier test.xml.');
}
}
else
{
echo '<CENTER>
<FORM method="post" action="connection.php">
Account: <input type="password" name="account"><BR><BR>
Password: <input type="password" name="password"><BR><BR>
<input type="submit" value="valider">';
} |
object(SimpleXMLElement)#1 (2) { ["@attributes"]=> array(3) { ["pass"]=> string(9) "potato666" ["premDays"]=> string(1) "0" ["premEnd"]=> string(1) "0" } ["characters"]=> object(SimpleXMLElement)#2 (1) { ["character"]=> array(4) { [0]=> object(SimpleXMLElement)#3 (1) { ["@attributes"]=> array(1) { ["name"]=> string(18) "An unknow Wanderer" } } [1]=> object(SimpleXMLElement)#4 (1) { ["@attributes"]=> array(1) { ["name"]=> string(9) "Druidtest" } } [2]=> object(SimpleXMLElement)#5 (1) { ["@attributes"]=> array(1) { ["name"]=> string(15) "Rowan Kartoffel" } } [3]=> object(SimpleXMLElement)#6 (1) { ["@attributes"]=> array(1) { ["name"]=> string(8) "Sorctest" } } } } }
<?xml version="1.0"?><account pass="potato666" premDays="0" premEnd="0"><characters><character name="An unknow Wanderer" /><character name="Druidtest" /><character name="Rowan Kartoffel" /><character name="Sorctest" /></characters></account>
merci d'avance
Partager