Bonjour j'ai un problème qui m'empeche d'ajouter toute les données que j'extrait dans un fichier xml .

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
	$fp = fopen("DOSSIER370.xml","r"); //ouverture en lecture
	$xmlstr = "";
	while (!feof($fp)) { //on parcourt toutes les lignes
		$xmlstr .= fgets($fp, 4096); // lecture du contenu de la ligne
	}
 
	$xmlObject=new SimpleXMLElement($xmlstr);
 
	$db=mysql_connect("localhost", "root") or die("connection impossible");
	mysql_select_db("projet",$db) or die ("base non trouvé");
 
	class agent
{
public $matricule;
public $dateentree;
public $civilite;
public $nomusuel;
public $nompatronymique;
public $nommarital;
public $prenom;
}
 
$i=0;
$compte = $xmlObject->xpath('//dsml:dsml/dsml:directory-entries/dsml:entry/dsml:attr[@name="matricule"]');
  $c = count($compte); 
  echo $c . "\n";
		$result = $xmlObject->xpath('//dsml:dsml/dsml:directory-entries/dsml:entry/dsml:attr[@name="matricule"]/dsml:value');
		$result1= $xmlObject->xpath('//dsml:dsml/dsml:directory-entries/dsml:entry/dsml:attr[@name="entree"]/dsml:value');			
		$result2= $xmlObject->xpath('//dsml:dsml/dsml:directory-entries/dsml:entry/dsml:attr[@name="civilite"]/dsml:value');
		$result3= $xmlObject->xpath('//dsml:dsml/dsml:directory-entries/dsml:entry/dsml:attr[@name="nomUsuel"]/dsml:value');
		$result4= $xmlObject->xpath('//dsml:dsml/dsml:directory-entries/dsml:entry/dsml:attr[@name="nomPatronymique"]/dsml:value');
		$result5= $xmlObject->xpath('//dsml:dsml/dsml:directory-entries/dsml:entry/dsml:attr[@name="nomMarital"]/dsml:value');
		$result6= $xmlObject->xpath('//dsml:dsml/dsml:directory-entries/dsml:entry/dsml:attr[@name="prenom"]/dsml:value');
 
		foreach ($result as $title) {  
		$ag[$i]=new agent;
		$ag[$i]->matricule=$title;
		$i+=1;
		 }
		$i=0;
		foreach ($result1 as $title1) { 
 
		$ag[$i]->dateentree=$title1;
		$i+=1;
		 }
		$i=0;	
		foreach ($result2 as $title2) { 
 
		$ag[$i]->civilite=$title2;
		$i+=1;		
		 "\n";  }
		$i=0;
		foreach ($result3 as $title3) {  
		$ag[$i]->nomusuel=$title3;
		$i+=1;
		  }
		$i=0;
		foreach ($result4 as $title4) {  
		$ag[$i]->nompatronymique=$title4;
		$i+=1;
		  }
		$i=0;
		foreach ($result5 as $title5) {  
		$ag[$i]->nommarital=$title5;
		$i+=1;
		  }
		$i=0;
		foreach ($result6 as $title6) {  
		$ag[$i]->prenom=$title6;
		$i+=1;
		  }
		$i=0;
 
	while($i!=$c) 
		{
		$title=$ag[$i]->matricule;
		$title1=$ag[$i]->dateentree;
		$title2=$ag[$i]->civilite;
		$title3=$ag[$i]->nomusuel;
		$title4=$ag[$i]->nompatronymique;
		$title5=$ag[$i]->nommarital;
		$title6=$ag[$i]->prenom;
		$controle="select matricule 
		from agent
		where matricule=$title";
		$resul = mysql_query($controle) or die("erreur sur la requete sql");
 
		if(mysql_num_rows ($resul )>0){
echo"<br>enregistrement deja present pour l'agent $title6 $title3 ";
}
 
		else{
		$sql="INSERT INTO AGENT (matricule,entree,civilite,nomUsuel,nomPatronymique,nomMarital,prenom)
		values('$title','$title1','$title2','$title3','$title4','$title5','$title6')";
		mysql_query($sql) or die("erreur sur la requete sql");
		}
	$i++; 
 
		}
	mysql_close($db);
	fclose($fp);
 
?>
une fois mon code executer la table contient seulement 10enregistrements alors que quand je fait un echo de $c j'en ai plus de 3000.
j'ai aussi tester une boucle for a la place du while mais meme resultats.