Hallo,
evtl. kann mir hier ja jemand helfen.
Also ich hatte vor längerer Zeit schonmal ein Thema aufgemacht
http://www.webmaster-resource.de/forum/php/phpxml+probleme+beim+ausgeben+von+xml+mit+php-t464.0.htmlIch hatte das ganze alles zum laufen bekommen jedoch nach einer Pause das Script zu benutzen funktioniert es aufeinmal nicht mehr richtig. Alle Sonderzeichen werden mir als Kryptische Zeichen angezeigt.
Beispiel:
Angesengter Großhelm
Antìbus usw.
Hier nun mal das Script:
xml1.php
<?php
$xml=$_POST['xml'];
$rid=$_POST['rid'];
if (!empty($rid) AND !empty($xml))
{
$xml=stripslashes($xml);
$Datei = "1.xml";
$FilePointer = fopen($Datei, "w+");
fwrite($FilePointer, $xml);
fclose($FilePointer);
include "xml.php";
}
if (!empty($rid) AND empty($xml))
{?>
<form method="post" action="index.php?show=xml1">
<table>
<tr>
<td>Dkp String</td>
</tr>
<tr>
<td><textarea cols="100" rows="40" name="xml"></textarea></td>
</tr>
<tr>
<td>
<input type="hidden" name="rid" value="<?php echo $rid; ?>">
<input type="submit" name="senden" value="Senden"></td>
</tr>
</table>
</form>
<?php }?>
xml.php
<?php
function uni_code($string){
// Kleine Funktion um in XML unzulässige Zeichen zu ersetzen
$zeichen = array(" ","¡","¢","£","¤","¥","¦","§","¨","©","ª","«","¬","","®","¯","°","±","²","³","´","µ","¶","·","¸","¹","º","»","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ");
$ersetzung = array("&#38;#160;","&#38;#161;","&#38;#162;","&#38;#163;","&#38;#164;","&#38;#165;","&#38;#166;","&#38;#167;","&#38;#168;","&#38;#169;","&#38;#170;","&#38;#171;","&#38;#172;","&#38;#173;","&#38;#174;","&#38;#175;","&#38;#176;","&#38;#177;","&#38;#178;","&#38;#179;","&#38;#180;","&#38;#181;","&#38;#182;","&#38;#183;","&#38;#184;","&#38;#185;","&#38;#186;","&#38;#187;","&#38;#188;","&#38;#189;","&#38;#190;","&#38;#191;","&#38;#192;","&#38;#193;","&#38;#194;","&#38;#195;","&#38;#196;","&#38;#197;","&#38;#198;","&#38;#199;","&#38;#200;","&#38;#201;","&#38;#202;","&#38;#203;","&#38;#204;","&#38;#205;","&#38;#206;","&#38;#207;","&#38;#208;","&#38;#209;","&#38;#210;","&#38;#211;","&#38;#212;","&#38;#213;","&#38;#214;","&#38;#215;","&#38;#216;","&#38;#217;","&#38;#218;","&#38;#219;","&#38;#220;","&#38;#221;","&#38;#222;","&#38;#223;","&#38;#224;","&#38;#225;","&#38;#226;","&#38;#227;","&#38;#228;","&#38;#229;","&#38;#230;","&#38;#231;","&#38;#232;","&#38;#233;","&#38;#234;","&#38;#235;","&#38;#236;","&#38;#237;","&#38;#238;","&#38;#239;","&#38;#240;","&#38;#241;","&#38;#242;","&#38;#243;","&#38;#244;","&#38;#245;","&#38;#246;","&#38;#247;","&#38;#248;","&#38;#249;","&#38;#250;","&#38;#251;","&#38;#252;","&#38;#253;","&#38;#254;","&#38;#255;");
return str_replace($zeichen,$ersetzung,$string);
}
$Daten = file('1.xml'); // Daten in ein Array einlesen
foreach($Daten as $key => $value){ // Array durchlaufen
$val1 = explode('>',$value); // Werte stehen ja immer nach einem >
if($val1[1]) // Falls des [1] gibt, ist ein Wert vorhanden
{
$val2 = explode('<',$val1[1]); // jetzt noch das Ende finden, ist ja immer <
if($val2[0]) // der Wert liegt jetzt im index [0]
{
$Daten[$key]=ereg_replace($val2[0],uni_code($val2[0]),$Daten[$key]);
// Wert kodieren
}
}
}
// ab hier habe ich keine Ahnung, ist der Code von Christian bis auf $Daten_clean
$Daten_clean = implode('',$Daten);
$Parser = xml_parser_create();
xml_parse_into_struct($Parser, $Daten_clean, $arrValues, $arrIndex);
xml_parser_free($Parser);
$counter=count($arrIndex[ITEMNAME]);
$counter=$counter - 1;
for ($i=0; $i<=$counter; $i++)
{
$o=$arrIndex[ITEMNAME][$i];
$itemname=$o;
$itemname2=$arrValues[$itemname][value];
$itemname2=addslashes($itemname2);
$itemid=$itemname + 1;
$itemid2=$arrValues[$itemid][value];
$itemid2=preg_split("/:/",$itemid2);
//$icon=$itemid + 1;
//$icon2=$arrValues[$icon][value];
//$class=$icon + 1;
//$class2=$arrValues[$class][value];
//$subclass=$class + 1;
//$subclass2=$arrValues[$subclass][value];
//$color=$subclass + 1;
//$color2=$arrValues[$color][value];
$count=$itemid + 1;
$count2=$arrValues[$count][value];
$player=$count + 1;
$player2=$arrValues[$player][value];
$time=$player + 1;
$time2=$arrValues[$time][value];
$zone=$time + 2;
$zone2=$arrValues[$zone][value];
$boss=$zone + 1;
$boss2=$arrValues[$boss][value];
$boss2=addslashes($boss2);
$found=0;
$sql1="SELECT itemname, player, anzahl FROM itemcache WHERE itemname='$itemname2'";
$data1=mysql_query($sql1, $db);
while ($checkitem=mysql_fetch_object($data1)) {
$found++;
$anzahl=$checkitem->anzahl + 1;
$playerup="$checkitem->player, $player2";
}
$foundr=0;
$sql2="SELECT itemlink, player, raid FROM itemplayer WHERE itemlink='$itemid2[0]' AND player='$player2' AND raid='$rid'";
$data2=mysql_query($sql2, $db);
while ($checkr=mysql_fetch_object($data2)) {
$foundr++;
}
if (empty($foundr))
{
if (empty($found))
{
$sql3="INSERT INTO itemcache (itemname, itemlink, itemcolor, itemicon, boss, zone, anzahl, player, itemhtml, raid) VALUES ('$itemname2', '$itemid2[0]', '', '', '$boss2', '$zone2', '1', '$player2', '', '$rid')";
$sqlaction1=mysql_query($sql3, $db) or die (mysql_error());
$sql4="INSERT INTO itemplayer (itemlink, player, raid) VALUES ('$itemid2[0]', '$player2', '$rid')";
$sqlaction2=mysql_query($sql4, $db) or die (mysql_error());
}
else
{
$sql5="UPDATE itemcache SET anzahl='$anzahl', player='$playerup' WHERE itemname='$itemname2'";
$sqlaction3=mysql_query($sql5, $db) or die (mysql_error());
$sql6="INSERT INTO itemplayer (itemlink, player, raid) VALUES ('$itemid2[0]', '$player2', '$rid')";
$sqlaction4=mysql_query($sql6, $db) or die (mysql_error());
}
}
}
print "Raid Items erfolgreich eingetragen.";
?>
Der zu bearbeitende Text ist:
<?xml version="1.0"?><!DOCTYPE ML_Raidtracker PUBLIC "-//MLdkp//DTD ML_Raidtracker V 1.5//EN" "http://www.mldkp.net/dtds/1.0/ML_Raidtracker.dtd"><raidinfo><version>1.5</version><start>1231696268</start><end>1231710960</end><realm>Khaz'goroth</realm><zone>Naxxramas</zone><difficulty>2</difficulty><instanceid>5052307</instanceid><exporter>Psychokiller</exporter><playerinfos></playerinfos><bosskills><bosskill><name>Anub'Rekhan</name><time>1231698496</time></bosskill><bosskill><name>Grand Widow Faerlina</name><time>1231699462</time></bosskill><bosskill><name>Maexxna</name><time>1231700856</time></bosskill><bosskill><name>Noth The Plaguebringer</name><time>1231702040</time></bosskill><bosskill><name>Heigan the Unclean</name><time>1231702950</time></bosskill><bosskill><name>Loatheb</name><time>1231703880</time></bosskill><bosskill><name>Instructor Razuvious</name><time>1231705655</time></bosskill><bosskill><name>Gothik the Harvester</name><time>1231707635</time></bosskill><bosskill><name>Four Horsemen</name><time>1231710149</time></bosskill></bosskills><wipes><wipe><time>1231706752</time></wipe><wipe><time>1231708789</time></wipe><wipe><time>1231709438</time></wipe></wipes><joins></joins><leaves></leaves><loots><loot><itemname>Angesengter Großhelm</itemname><itemid>39723:0:0:0:0:0:0:1280381704:80</itemid><count>1</count><player>Grogal</player><time>1231699509</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Grand Widow Faerlina</boss></loot><loot><itemname>Berührung des Grauens</itemname><itemid>40335:0:0:0:0:0:0:1298057582:80</itemid><count>1</count><player>Ondit</player><time>1231707714</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Gothik the Harvester</boss></loot><loot><itemname>Bindungen der bedauernswerten Beute</itemname><itemid>39764:0:0:0:0:0:0:1315114750:80</itemid><count>1</count><player>Psychokiller</player><time>1231700947</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Maexxna</boss></loot><loot><itemname>Bindungen des Klapprigen</itemname><itemid>40209:0:0:0:0:0:0:1285619419:80</itemid><count>1</count><player>Kadlin</player><time>1231703051</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Heigan the Unclean</boss></loot><loot><itemname>Brustplatte des verlorenen Beschützers</itemname><itemid>40626:0:0:0:0:0:0:1535700794:80</itemid><count>1</count><player>Mith</player><time>1231710802</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Trash mob</boss></loot><loot><itemname>Brustplatte des verlorenen Eroberers</itemname><itemid>40625:0:0:0:0:0:0:1267265338:80</itemid><count>1</count><player>Phoedonix</player><time>1231710781</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Trash mob</boss></loot><loot><itemname>Der unmögliche Traum</itemname><itemid>40244:0:0:0:0:0:0:1042310536:80</itemid><count>1</count><player>Mardoc</player><time>1231703970</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Loatheb</boss></loot><loot><itemname>Dämmerungswanderer</itemname><itemid>39701:0:0:0:0:0:0:1564587004:80</itemid><count>1</count><player>Antìbus</player><time>1231698600</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Anub'Rekhan</boss><note><![CDATA[2nd equip]]></note></loot><loot><itemname>Eingesponnener Tod</itemname><itemid>39714:0:0:0:0:0:0:1833022460:80</itemid><count>1</count><player>Zonenboy</player><time>1231698627</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Anub'Rekhan</boss></loot><loot><itemname>Fußlappen der niederträchtigen List</itemname><itemid>40243:0:0:0:0:0:0:773875080:80</itemid><count>1</count><player>Zonenboy</player><time>1231703936</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Loatheb</boss></loot><loot><itemname>Fußlappen des zerrissenen Netzes</itemname><itemid>39762:0:0:0:0:0:0:1046679294:80</itemid><count>1</count><player>Burnóut</player><time>1231700934</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Maexxna</boss></loot><loot><itemname>Gamaschen der fehlgeschlagenen Flucht</itemname><itemid>40331:0:0:0:0:0:0:1029622126:80</itemid><count>1</count><player>Huntingbunny</player><time>1231707683</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Gothik the Harvester</boss></loot><loot><itemname>Geschätzte Bindungen</itemname><itemid>40323:0:0:0:0:0:0:-2082371634:80</itemid><count>1</count><player>disenchanted</player><time>1231705785</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Instructor Razuvious</boss></loot><loot><itemname>Gewitteramulett</itemname><itemid>40064:0:0:0:0:0:0:-1813936178:80</itemid><count>1</count><player>Bioholix</player><time>1231705826</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Instructor Razuvious</boss></loot><loot><itemname>Gothiks Gugel</itemname><itemid>40339:0:0:0:0:0:0:1566493038:80</itemid><count>1</count><player>Cloee</player><time>1231707745</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Gothik the Harvester</boss></loot><loot><itemname>Grabeshelm</itemname><itemid>40344:0:0:0:0:0:0:730394426:80</itemid><count>1</count><player>Huntingbunny</player><time>1231710758</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Trash mob</boss></loot><loot><itemname>Grimmiger Tribut</itemname><itemid>40256:0:0:0:0:0:0:1834928494:80</itemid><count>1</count><player>Garisson</player><time>1231707772</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Gothik the Harvester</boss></loot><loot><itemname>Handschuhe des Tanzbären</itemname><itemid>40238:0:0:0:0:0:0:1554054875:80</itemid><count>1</count><player>disenchanted</player><time>1231703090</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Heigan the Unclean</boss></loot><loot><itemname>Handschuhe des gefallenen Zauberers</itemname><itemid>40197:0:0:0:0:0:0:1824725760:80</itemid><count>1</count><player>Ondit</player><time>1231702161</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Trash mob</boss></loot><loot><itemname>Ketten der Verehrung</itemname><itemid>40071:0:0:0:0:0:0:-1925073924:80</itemid><count>1</count><player>Goroth</player><time>1231698684</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Anub'Rekhan</boss></loot><loot><itemname>Ketten der Verehrung</itemname><itemid>40071:0:0:0:0:0:0:2085688072:80</itemid><count>1</count><player>Mardoc</player><time>1231699601</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Grand Widow Faerlina</boss></loot><loot><itemname>Ketten der Verehrung</itemname><itemid>40071:0:0:0:0:0:0:2093161216:80</itemid><count>1</count><player>Ondit</player><time>1231702192</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Trash mob</boss></loot><loot><itemname>Korrekte Bindungen</itemname><itemid>39731:0:0:0:0:0:0:1548817160:80</itemid><count>1</count><player>Ondit</player><time>1231699547</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Grand Widow Faerlina</boss></loot><loot><itemname>Mantel des Verdorbenen</itemname><itemid>40286:0:0:0:0:0:0:998829882:80</itemid><count>1</count><player>Nekromanta</player><time>1231710766</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Trash mob</boss></loot><loot><itemname>Mantel des verlorenen Beschützers</itemname><itemid>40638:0:0:0:0:0:0:1579181448:80</itemid><count>1</count><player>Burnóut</player><time>1231704009</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Loatheb</boss></loot><loot><itemname>Mantel des verlorenen Beschützers</itemname><itemid>40638:0:0:0:0:0:0:1310745992:80</itemid><count>1</count><player>Psychokiller</player><time>1231704001</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Loatheb</boss></loot><loot><itemname>Salonschärpe</itemname><itemid>39721:0:0:0:0:0:0:2101457916:80</itemid><count>1</count><player>Bioholix</player><time>1231698662</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Anub'Rekhan</boss></loot><loot><itemname>Schal der alten Maid</itemname><itemid>40253:0:0:0:0:0:0:1822490331:80</itemid><count>1</count><player>Bioholix</player><time>1231703116</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Heigan the Unclean</boss></loot><loot><itemname>Schienbeinschützer der Buße</itemname><itemid>39734:0:0:0:0:0:0:1817252616:80</itemid><count>1</count><player>disenchanted</player><time>1231699574</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Grand Widow Faerlina</boss></loot><loot><itemname>Schulterschutz der Möglichkeiten</itemname><itemid>40185:0:0:0:0:0:0:1287854848:80</itemid><count>1</count><player>Mith</player><time>1231702103</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Noth The Plaguebringer</boss></loot><loot><itemname>Stulpen der leitenden Hand</itemname><itemid>40316:0:0:0:0:0:0:1675724750:80</itemid><count>1</count><player>Garisson</player><time>1231705812</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Instructor Razuvious</boss></loot><loot><itemname>Stängelhautgürtel</itemname><itemid>40205:0:0:0:0:0:0:1017183963:80</itemid><count>1</count><player>Zonenboy</player><time>1231703039</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Heigan the Unclean</boss></loot><loot><itemname>Tiefenkristall</itemname><itemid>34057:0:0:0:0:0:0:-1869274435:80</itemid><count>3</count><player>bank</player><time>1231699582</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Grand Widow Faerlina</boss></loot><loot><itemname>Tuch der Leuchtkraft</itemname><itemid>40251:0:0:0:0:0:0:1851985662:80</itemid><count>1</count><player>Kampfeagle</player><time>1231701013</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Maexxna</boss></loot><loot><itemname>Tunika des maskierten Leidens</itemname><itemid>40193:0:0:0:0:0:0:1556290304:80</itemid><count>1</count><player>Burnóut</player><time>1231702123</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Noth The Plaguebringer</boss></loot><loot><itemname>Zuverlässige Stahlsabatons</itemname><itemid>40320:0:0:0:0:0:0:1944160206:80</itemid><count>1</count><player>Garisson</player><time>1231705817</time><difficulty>2</difficulty><zone>Naxxramas</zone><boss>Instructor Razuvious</boss></loot></loots></raidinfo>
Ich hab so nen bischen den Verdacht das die Sonderzeichen umwandel Funktion irgendwie nicht richtig funktioniert.
Hoffe ihr könnt mir helfen!
MfG
Psycho