Hi,
zuerst mal ich bin kein Profi, ich programmiere ab und zu mal wenn ich nichts Fertiges finde.
Leider stosse ich dann auch meistens auf Probleme.
Also XML Struktur in der Datei die ich erhalte.
[COLOR=#0000ff]<[/COLOR][COLOR=#990000]DESCRIPTION_LIBRARY action[/COLOR][COLOR=#0000ff]="[/COLOR]A[COLOR=#0000ff]">[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]UCo[/COLOR][COLOR=#0000ff]>[/COLOR]DE[COLOR=#0000ff]</[/COLOR][COLOR=#990000]UCo[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]ULa[/COLOR][COLOR=#0000ff]>[/COLOR]EN[COLOR=#0000ff]</[/COLOR][COLOR=#990000]ULa[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]NP[/COLOR][COLOR=#0000ff]>[/COLOR]0[COLOR=#0000ff]</[/COLOR][COLOR=#990000]NP[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]PVC[/COLOR][COLOR=#0000ff]>[/COLOR]AC2[COLOR=#0000ff]</[/COLOR][COLOR=#990000]PVC[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]CCo[/COLOR] [COLOR=#0000ff]/>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]MOH[/COLOR] [COLOR=#0000ff]/>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]CA[/COLOR][COLOR=#0000ff]>[/COLOR]SB[COLOR=#0000ff]</[/COLOR][COLOR=#990000]CA[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]SO[/COLOR][COLOR=#0000ff]>[/COLOR]L[COLOR=#0000ff]</[/COLOR][COLOR=#990000]SO[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]CO[/COLOR][COLOR=#0000ff]>[/COLOR]5PU[COLOR=#0000ff]</[/COLOR][COLOR=#990000]CO[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]CD[/COLOR] [COLOR=#0000ff]/>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]DaF[/COLOR][COLOR=#0000ff]>[/COLOR]2009-01-01[COLOR=#0000ff]</[/COLOR][COLOR=#990000]DaF[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]DaT[/COLOR][COLOR=#0000ff]>[/COLOR]2099-12-31[COLOR=#0000ff]</[/COLOR][COLOR=#990000]DaT[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]MyF[/COLOR][COLOR=#0000ff]>[/COLOR]2012[COLOR=#0000ff]</[/COLOR][COLOR=#990000]MyF[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]MyT[/COLOR][COLOR=#0000ff]>[/COLOR]9999[COLOR=#0000ff]</[/COLOR][COLOR=#990000]MyT[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]SuF[/COLOR] [COLOR=#0000ff]/>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]DeT[/COLOR][COLOR=#0000ff]>[/COLOR]Test[COLOR=#0000ff]</[/COLOR][COLOR=#990000]DeT[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]DeC[/COLOR][COLOR=#0000ff]>[/COLOR]5PU SB[COLOR=#0000ff]</[/COLOR][COLOR=#990000]DeC[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]SN[/COLOR][COLOR=#0000ff]>[/COLOR]1[COLOR=#0000ff]</[/COLOR][COLOR=#990000]SN[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]MG[/COLOR][COLOR=#0000ff]>[/COLOR]00[COLOR=#0000ff]</[/COLOR][COLOR=#990000]MG[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]UpD[/COLOR][COLOR=#0000ff]>[/COLOR]2012-03-02[COLOR=#0000ff]</[/COLOR][COLOR=#990000]UpD[/COLOR][COLOR=#0000ff]>[/COLOR]
[COLOR=#0000ff]</[/COLOR][COLOR=#990000]DESCRIPTION_LIBRARY[/COLOR][COLOR=#0000ff]>[/COLOR]
[COLOR=#0000ff][/COLOR]
[COLOR=#0000ff]ich kann alles auslesen allerdings erhalte ich niemals diesen action= Wert.[/COLOR]
[COLOR=#0000ff]Oder kann auf ihn im Code reagieren.[/COLOR]
[COLOR=#0000ff]Da dieser beschreibt wie mit den folgenden Daten zu verfahren ist benötige ich diese Info.[/COLOR]
[COLOR=#0000ff][/COLOR]
[COLOR=#0000ff]Mein code mit dem ich das zur Zeit auslese.[/COLOR]
[COLOR=#0000ff]Ich experimentiere mit der Zeile [/COLOR]
if ($key == 'DESCRIPTION_LIBRARY')
aber irgendwie klappt es nie.
Wäre um jede Hilfe dankbar.
<?php
$text ="";
class Desc {
// var $action;
var $UCo;
var $ULa;
var $NP;
var $PVC;
var $CCo;
var $MOH;
var $CA;
var $SO;
var $CO;
var $CD;
var $DaF;
var $DaT;
var $MyF;
var $MyT;
var $DeT;
var $DeC;
var $SN;
var $MG;
var $UpD;
function Desc ($aa)
{
foreach ($aa as $k=>$v)
$this->$k = $aa[$k];
}
}
function readDatabase($filename)
{
// read the XML database of aminoacids
$data = implode("", file($filename));
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $tags);
xml_parser_free($parser);
// loop through the structures
foreach ($tags as $key=>$val) {
if ($key == 'DESCRIPTION_LIBRARY') {
$Desc_cont = $val;
// each contiguous pair of array entries are the
// lower and upper range for each DLecule definition
for ($i=0; $i < count($Desc_cont); $i+=2) {
$offset = $Desc_cont[$i] + 1;
$len = $Desc_cont[$i + 1] - $offset;
$tdb[] = parseDesc(array_slice($values, $offset, $len));
}
} else {
continue;
}
}
return $tdb;
}
function parseDesc($mvalues)
{
$text= "";
$out ="";
for ($i=0; $i < count($mvalues); $i++) {
$DL[$mvalues[$i]["tag"]] = $mvalues[$i]["value"];
$text = " " . $i . " " . $DL[$mvalues[$i]["tag"]] . " ";
$out = $out . $text;
}
echo ($out . "</p>");
return new Desc($DL);
}
$db = readDatabase("Z:\DL_144.xml");
?>
zuerst mal ich bin kein Profi, ich programmiere ab und zu mal wenn ich nichts Fertiges finde.
Leider stosse ich dann auch meistens auf Probleme.
Also XML Struktur in der Datei die ich erhalte.
[COLOR=#0000ff]<[/COLOR][COLOR=#990000]DESCRIPTION_LIBRARY action[/COLOR][COLOR=#0000ff]="[/COLOR]A[COLOR=#0000ff]">[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]UCo[/COLOR][COLOR=#0000ff]>[/COLOR]DE[COLOR=#0000ff]</[/COLOR][COLOR=#990000]UCo[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]ULa[/COLOR][COLOR=#0000ff]>[/COLOR]EN[COLOR=#0000ff]</[/COLOR][COLOR=#990000]ULa[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]NP[/COLOR][COLOR=#0000ff]>[/COLOR]0[COLOR=#0000ff]</[/COLOR][COLOR=#990000]NP[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]PVC[/COLOR][COLOR=#0000ff]>[/COLOR]AC2[COLOR=#0000ff]</[/COLOR][COLOR=#990000]PVC[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]CCo[/COLOR] [COLOR=#0000ff]/>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]MOH[/COLOR] [COLOR=#0000ff]/>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]CA[/COLOR][COLOR=#0000ff]>[/COLOR]SB[COLOR=#0000ff]</[/COLOR][COLOR=#990000]CA[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]SO[/COLOR][COLOR=#0000ff]>[/COLOR]L[COLOR=#0000ff]</[/COLOR][COLOR=#990000]SO[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]CO[/COLOR][COLOR=#0000ff]>[/COLOR]5PU[COLOR=#0000ff]</[/COLOR][COLOR=#990000]CO[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]CD[/COLOR] [COLOR=#0000ff]/>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]DaF[/COLOR][COLOR=#0000ff]>[/COLOR]2009-01-01[COLOR=#0000ff]</[/COLOR][COLOR=#990000]DaF[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]DaT[/COLOR][COLOR=#0000ff]>[/COLOR]2099-12-31[COLOR=#0000ff]</[/COLOR][COLOR=#990000]DaT[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]MyF[/COLOR][COLOR=#0000ff]>[/COLOR]2012[COLOR=#0000ff]</[/COLOR][COLOR=#990000]MyF[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]MyT[/COLOR][COLOR=#0000ff]>[/COLOR]9999[COLOR=#0000ff]</[/COLOR][COLOR=#990000]MyT[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]SuF[/COLOR] [COLOR=#0000ff]/>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]DeT[/COLOR][COLOR=#0000ff]>[/COLOR]Test[COLOR=#0000ff]</[/COLOR][COLOR=#990000]DeT[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]DeC[/COLOR][COLOR=#0000ff]>[/COLOR]5PU SB[COLOR=#0000ff]</[/COLOR][COLOR=#990000]DeC[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]SN[/COLOR][COLOR=#0000ff]>[/COLOR]1[COLOR=#0000ff]</[/COLOR][COLOR=#990000]SN[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]MG[/COLOR][COLOR=#0000ff]>[/COLOR]00[COLOR=#0000ff]</[/COLOR][COLOR=#990000]MG[/COLOR][COLOR=#0000ff]>[/COLOR]
[FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]UpD[/COLOR][COLOR=#0000ff]>[/COLOR]2012-03-02[COLOR=#0000ff]</[/COLOR][COLOR=#990000]UpD[/COLOR][COLOR=#0000ff]>[/COLOR]
[COLOR=#0000ff]</[/COLOR][COLOR=#990000]DESCRIPTION_LIBRARY[/COLOR][COLOR=#0000ff]>[/COLOR]
[COLOR=#0000ff][/COLOR]
[COLOR=#0000ff]ich kann alles auslesen allerdings erhalte ich niemals diesen action= Wert.[/COLOR]
[COLOR=#0000ff]Oder kann auf ihn im Code reagieren.[/COLOR]
[COLOR=#0000ff]Da dieser beschreibt wie mit den folgenden Daten zu verfahren ist benötige ich diese Info.[/COLOR]
[COLOR=#0000ff][/COLOR]
[COLOR=#0000ff]Mein code mit dem ich das zur Zeit auslese.[/COLOR]
[COLOR=#0000ff]Ich experimentiere mit der Zeile [/COLOR]
if ($key == 'DESCRIPTION_LIBRARY')
aber irgendwie klappt es nie.
Wäre um jede Hilfe dankbar.
<?php
$text ="";
class Desc {
// var $action;
var $UCo;
var $ULa;
var $NP;
var $PVC;
var $CCo;
var $MOH;
var $CA;
var $SO;
var $CO;
var $CD;
var $DaF;
var $DaT;
var $MyF;
var $MyT;
var $DeT;
var $DeC;
var $SN;
var $MG;
var $UpD;
function Desc ($aa)
{
foreach ($aa as $k=>$v)
$this->$k = $aa[$k];
}
}
function readDatabase($filename)
{
// read the XML database of aminoacids
$data = implode("", file($filename));
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $tags);
xml_parser_free($parser);
// loop through the structures
foreach ($tags as $key=>$val) {
if ($key == 'DESCRIPTION_LIBRARY') {
$Desc_cont = $val;
// each contiguous pair of array entries are the
// lower and upper range for each DLecule definition
for ($i=0; $i < count($Desc_cont); $i+=2) {
$offset = $Desc_cont[$i] + 1;
$len = $Desc_cont[$i + 1] - $offset;
$tdb[] = parseDesc(array_slice($values, $offset, $len));
}
} else {
continue;
}
}
return $tdb;
}
function parseDesc($mvalues)
{
$text= "";
$out ="";
for ($i=0; $i < count($mvalues); $i++) {
$DL[$mvalues[$i]["tag"]] = $mvalues[$i]["value"];
$text = " " . $i . " " . $DL[$mvalues[$i]["tag"]] . " ";
$out = $out . $text;
}
echo ($out . "</p>");
return new Desc($DL);
}
$db = readDatabase("Z:\DL_144.xml");
?>
Kommentar