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
|
<?php
// Classe XMLManager
class XMLManager
{
private $domfile;
private $domxpath;
private $curlang;
private $curfile;
private $filelock;
/*******************************************************************************************************************
METHODES PUBLIQUES
*******************************************************************************************************************/
//Constructeur de la classe
public function __construct( $filename, $language )
{
$this->curlang = $language;
$this->curfile = $filename;
$this->domfile = new DOMDocument('1.0', 'iso-8859-1');
$this->domfile->preserveWhiteSpace = false; //On ne se soucie pas des espaces blancs.
$this->filelock = fopen( $filename.'.checker','a+'); //Ouverture du fichier de sécurité.
$this->domfile->load($filename);
$this->domxpath = new DOMXPath($this->domfile);
}
//Destructeur de la classe
public function __destruct()
{
unset($this->curfile);
unset($this->domfile);
unset($this->domxpath);
unset($this->curlang);
unset($this->filelock);
}
//Méthode qui retourne les données d'un noeud, l'élément pour la langue est inséré automatiquement.
public function getXPath( $xpathquery )
{
$textnode = $this->domxpath->query( $xpathquery.'/'.$this->curlang );
return utf8_decode($textnode->item(0)->nodeValue);
}
} |
Partager