Valid XHTML     Valid CSS2    

Listing du fichier genereXml.php

 

00001     <?php
00002     
# (gH) -_- genereXml.php ; TimeStamp (unix) : 29 Septembre 2012 vers 18:04
00003     
error_reporting(E_ALL | E_NOTICE | E_STRICT) ;
00004     
header
('Content-type: text/xml') ;
00005     
00006     
$pId = array() ;
00007     
$pClass = array() ;
00008     
$pLength = array() ;
00009     
$pSeq = array() ;
00010     
00011     include(
"genereXml-inc.php"
) ; # contient les données pour les séquences
00012     
00013     
$nbProt
= $pn ; # issu de genereXml-inc.php
00014     
00015     
$domtree
= new DOMDocument('1.0', 'UTF-8');
00016     
$rootElt
= $domtree->createElement("proteins");
00017     
$tmp
= $domtree->appendChild($rootElt);
00018     
00019     for (
$idp
=1;$idp<=$nbProt;$idp++) {
00020     
00021     
$prot
= $domtree->createElement("protein"); # nouvel élément <protein>
00022     
00023     
if (isset(
$_GET["i"])) { # identifiant
00024     
if (
$_GET["i"]=="e") {
00025     
$pi
= $domtree->createElement("identifiant",$pId[$idp]) ; # nouvel élément <identifiant>
00026     
$tmp
= $prot->appendChild($pi);
00027      } else {
00028     
$prot
->setAttribute("identifiant",$pId[$idp]) ; # nouvel attribut identifiant
00029     
} # fin si sur élément ou attribut
00030     
} # fin si sur i
00031     
00032     
if (isset(
$_GET["c"])) { # classe
00033     
if (
$_GET["c"]=="e") {
00034     
$pc
= $domtree->createElement("class",$pClass[$idp]) ;
00035     
$tmp
= $prot->appendChild($pc);
00036      } else {
00037     
$prot
->setAttribute("class",$pClass[$idp]) ;
00038      }
# fin si sur élément ou attribut
00039     
} # fin si sur c
00040     
00041     
if (isset(
$_GET["l"])) { # longueur
00042     
if (
$_GET["l"]=="e") {
00043     
$pl
= $domtree->createElement("longueur",$pLength[$idp]) ;
00044     
$tmp
= $prot->appendChild($pl);
00045      } else {
00046     
$prot
->setAttribute("longueur",$pLength[$idp]) ;
00047      }
# fin si sur élément ou attribut
00048     
} # fin si sur c
00049     
00050     
if (isset(
$_GET["s"])) { # sequence
00051     
if (
$_GET["s"]=="e") {
00052     
# une variante, sans doute moins lisible
00053     
$tmp
= $prot->appendChild( $domtree->createElement("sequence",$pSeq[$idp]) ) ;
00054      } else {
00055     
$prot
->setAttribute("sequence",$pSeq[$idp]) ;
00056      }
# fin si sur élément ou attribut
00057     
} # fin si sur s
00058     
00059      # ajout de la nouvelle protéines
00060     
00061     
$tmp
= $rootElt->appendChild($prot);
00062     
00063     } ;
# fin pour idp
00064     
00065     
echo
$domtree->saveXML();
00066     
00067     
00068     
?>

Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.

 

 

retour gH    Retour à la page principale de   (gH)