Listing du fichier genereXmlCmt.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 $cmt = $domtree->createComment("ceci est le haut du document");
00020 $tmp = $rootElt ->appendChild($cmt);
00021
00022 for ($idp=1;$idp<=$nbProt;$idp++) {
00023
00024 $prot = $domtree->createElement("protein"); # nouvel élément <protein>
00025 $cmt = $domtree->createComment(" ## protein number $idp ");
00026 $tmp = $prot->appendChild($cmt);
00027
00028 if (isset($_GET["i"])) { # identifiant
00029 if ($_GET["i"]=="e") {
00030 $pi = $domtree->createElement("identifiant",$pId[$idp]) ; # nouvel élément <identifiant>
00031 $tmp = $prot->appendChild($pi);
00032 } else {
00033 $prot->setAttribute("identifiant",$pId[$idp]) ; # nouvel attribut identifiant
00034 } # fin si sur élément ou attribut
00035 } # fin si sur i
00036
00037 if (isset($_GET["c"])) { # classe
00038 if ($_GET["c"]=="e") {
00039 $pc = $domtree->createElement("class",$pClass[$idp]) ;
00040 $tmp = $prot->appendChild($pc);
00041 } else {
00042 $prot->setAttribute("class",$pClass[$idp]) ;
00043 } # fin si sur élément ou attribut
00044 } # fin si sur c
00045
00046 if (isset($_GET["l"])) { # longueur
00047 if ($_GET["l"]=="e") {
00048 $pl = $domtree->createElement("longueur",$pLength[$idp]) ;
00049 $tmp = $prot->appendChild($pl);
00050 } else {
00051 $prot->setAttribute("longueur",$pLength[$idp]) ;
00052 } # fin si sur élément ou attribut
00053 } # fin si sur c
00054
00055 if (isset($_GET["s"])) { # sequence
00056 if ($_GET["s"]=="e") {
00057 # une variante, sans doute moins lisible
00058 $tmp = $prot->appendChild( $domtree->createElement("sequence",$pSeq[$idp]) ) ;
00059 } else {
00060 $prot->setAttribute("sequence",$pSeq[$idp]) ;
00061 } # fin si sur élément ou attribut
00062 } # fin si sur s
00063
00064 # ajout de la nouvelle protéines
00065
00066 $tmp = $rootElt->appendChild($prot);
00067
00068 } ; # fin pour idp
00069
00070 echo $domtree->saveXML();
00071
00072
00073 ?>
Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.
Retour à la page principale de (gH)