IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques et frameworks PHP Discussion :

[SimpleXML] pb parser le fichier correctement


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 27
    Points : 17
    Points
    17
    Par défaut [SimpleXML] pb parser le fichier correctement
    bonjour,

    voici un exemple de fichier xml que je doit traiter :

    Code XML : 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
    <bibtex:file>
    <bibtex:entry id="MR2356985">
    <bibtex:article>
    <bibtex:author>Akhmediev, Nail and Soto-Crespo, J. M. and Grelu, Philippe</bibtex:author>
    <bibtex:title>Spatiotemporal optical solitons in nonlinear dissipative media: from stationary light bullets to pulsating complexes</bibtex:title>
    <bibtex:journal>Chaos</bibtex:journal>
    <bibtex:fjournal>Chaos. An Interdisciplinary Journal of Nonlinear Science</bibtex:fjournal>
    <bibtex:volume>17</bibtex:volume>
    <bibtex:year>2007</bibtex:year>
    <bibtex:number>3</bibtex:number>
    <bibtex:pages>037112, 16</bibtex:pages>
    <bibtex:issn>1054-1500</bibtex:issn>
    <bibtex:coden>CHAOEH</bibtex:coden>
    <bibtex:mrclass>78A60 (35Q51 35Q55 35Q60)</bibtex:mrclass>
    <bibtex:mrnumber>MR2356985</bibtex:mrnumber>
    </bibtex:article>
    </bibtex:entry>
    <bibtex:entry id="MR2317453">
    <bibtex:article>
    <bibtex:author>Cano, F. and Moussu, R. and Sanz, F.</bibtex:author>
    <bibtex:title>Nonoscillating projections for trajectories of vector fields</bibtex:title>
    <bibtex:journal>J. Dyn. Control Syst.</bibtex:journal>
    <bibtex:fjournal>Journal of Dynamical and Control Systems</bibtex:fjournal>
    <bibtex:volume>13</bibtex:volume>
    <bibtex:year>2007</bibtex:year>
    <bibtex:number>2</bibtex:number>
    <bibtex:pages>173--176</bibtex:pages>
    <bibtex:issn>1079-2724</bibtex:issn>
    <bibtex:mrclass>37C10</bibtex:mrclass>
    <bibtex:mrnumber>MR2317453</bibtex:mrnumber>
    </bibtex:article>
    </bibtex:entry>
    </bibtex:file>

    Jusqu'a present je n'avai qu'une seul publication donc je n'avai pas de problème, mais se n'est plus le cas et cela me pause beaucoup de problème en effet ma méthode me permet d'afficher les resultats certe mais tout est melanger et je ne reussi plus a gere mes envoi d'information dans la base de données.

    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
    $xml = simplexml_load_file('xml/'.$nom_sans_ext.'.xml');
     
    foreach ($xml->xpath('//bibtex:entry') as $entry_xml)
    {
    	$id=$entry_xml['id'];
    	echo 'l\'id de l\'entry est :'.$id.'<br><br>';
     
    	//** Gestion des differents type de de document
    	//si c'est un article
    	if ($entry_xml->xpath('//bibtex:article'))
    	{
    		$type_xml = 'article';
    		foreach ($entry_xml->xpath('//bibtex:article') as $article_xml)
    		{
    			foreach ($article_xml->xpath('//bibtex:author') as $author_xml)
    			{
    				echo $author_xml.'<br><br>';
    			}
    			foreach ($article_xml->xpath('//bibtex:title') as $title_xml)
    			{
    				echo $title_xml.'<br><br>';
    			}
    			foreach ($article_xml->xpath('//bibtex:journal') as $journal_xml)
    			{
    				echo $journal_xml.'<br><br>';
    			}		
    			foreach ($article_xml->xpath('//bibtex:fjournal') as $fjournal_xml)
    			{
    				echo $fjournal_xml.'<br><br>';
    			}
    			foreach ($article_xml->xpath('//bibtex:volume') as $volume_xml)
    			{
    				echo $volume_xml.'<br><br>';
    			}
    			foreach ($article_xml->xpath('//bibtex:year') as $year_xml)
    			{
    				echo $year_xml.'<br><br>';
    			}
    			foreach ($article_xml->xpath('//bibtex:number') as $number_xml)
    			{
    				echo $number_xml.'<br><br>';
    			}
    			foreach ($article_xml->xpath('//bibtex:pages') as $pages_xml)
    			{
    				echo $pages_xml.'<br><br>';
    			}
    			foreach ($article_xml->xpath('//bibtex:issn') as $issn_xml)
    			{
    				echo $issn_xml.'<br><br>';
    			}
    			foreach ($article_xml->xpath('//bibtex:coden') as $coden_xml)
    			{
    				echo $coden_xml.'<br><br>';
    			}
    			foreach ($article_xml->xpath('//bibtex:mrclass') as $mrclass_xml)
    			{
    				echo $mrclass_xml.'<br><br>';
    			}
    			foreach ($article_xml->xpath('//bibtex:mrnumber') as $mrnumber_xml)
    			{
    				echo $mrnumber_xml.'<br><br>';
    			}
    			foreach ($article_xml->xpath('//bibtex:mrreviewer') as $mrreviewer_xml)
    			{
    				echo $mrreviewer_xml.'<br><br>';
    			}
    		}						
    	}
    	//Si c'est un incollection
    	elseif ($entry_xml->xpath('//bibtex:incollection'))
    	{
    		$type_xml = 'incollection';
    	}
    Que faire pour parser le fichier xml comme il faut afin d'envoyé les information dans la base de donnée ?

    Ou peut on solutionner le problème par un simple envoie dans la base de donner au milieu du code de traitement du xml ?

  2. #2
    Membre régulier Avatar de _FaFa_
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    103
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 103
    Points : 111
    Points
    111
    Par défaut
    Et quel est le problème que tu rencontres ?

Discussions similaires

  1. [XML] parser un fichier xml avec simplexml
    Par gtraxx dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 06/08/2011, 22h43
  2. [SimpleXML] probleme pour parser un fichier XML
    Par gilles974 dans le forum Bibliothèques et frameworks
    Réponses: 4
    Dernier message: 27/03/2008, 10h01
  3. [XML] Parser un fichier XML - SimpleXML
    Par Pepe67 dans le forum XML/XSL et SOAP
    Réponses: 1
    Dernier message: 05/07/2006, 11h39
  4. parser un fichier avec xerces
    Par traiangueul dans le forum XML/XSL et SOAP
    Réponses: 9
    Dernier message: 02/02/2004, 18h14
  5. parser un fichier html
    Par noarno dans le forum ASP
    Réponses: 2
    Dernier message: 10/12/2003, 17h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo