[Tableaux] Traiter le texte d'un fichier Xml comme variable Php
Bonjour,
Je souhaite créer un dictionnaire à partir d'une base textuelle.
Avant de programmer en php pour décompter les mots etc... j'ai besoin de passer un fichier xml en variable php.
J'ouvre mon fichier xml pour le parser.
J'utilise array_push() pour affecter la valeur de chaque ligne à la variable $text (un tableau) : mais j'obtiens un message d'erreur.
Warning: array_push() [function.array-push]: First argument should be an array in C:\wamp\www\query.php on line 25
Je ne vois pas ou se trouve le pb. Merci pour votre aide !
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
$fichier = "interventions.xml";
$text0= array();
function fonctionTexte($parseur, $data)
{ //echo $data;
array_push($text0, $data);
}
$parseurXML = xml_parser_create();
xml_set_character_data_handler($parseurXML, "fonctionTexte");
$fp = fopen($fichier, "r") or die("Impossible d'ouvrir le fichier XML");
while ( $ligneXML = fgets($fp, 1024))
{
xml_parse($parseurXML, $ligneXML, feof($fp)) or die("Erreur XML");
}
xml_parser_free($parseurXML); |