FrazeColder
Lt. Commander
- Registriert
- Okt. 2013
- Beiträge
- 1.718
Moin zusammen,
Ich habe leider ein Problem. Mein Code downloadet ein paar XML Files aus dem Internet und löscht ein paar Tags aus den jeweiligen XML Files. Das ist auch alles soweit kein Problem und funktioniert auch alles. Es ist auch im UTF-8 Format.
Allerdings seitdem ich noch 3 Methoden hinzugefügt habe mit denen ich die Values bearbeite, sind meine XML Files nicht mehr im UTF-8 Format und ich bekomme diese Fehlermeldung:
In Zeile 1423 steht: W㥣hter Von Mittelerde
Und ohne dass ich die Values bearbeite, sprich bevor ich die 3 Mehoden hinzugefügt habe ging alles, die XMLs waren in UTF 8 Format und in Zeile 1423 stand: Wächter von Mittelerde.
Hat jemand eine Idee wie ich das beheben kann und woran das liegt?
Dieser Code verstaucht das:
Vielen Dank und MfG!
Ich habe leider ein Problem. Mein Code downloadet ein paar XML Files aus dem Internet und löscht ein paar Tags aus den jeweiligen XML Files. Das ist auch alles soweit kein Problem und funktioniert auch alles. Es ist auch im UTF-8 Format.
Allerdings seitdem ich noch 3 Methoden hinzugefügt habe mit denen ich die Values bearbeite, sind meine XML Files nicht mehr im UTF-8 Format und ich bekomme diese Fehlermeldung:
Code:
"D:\Anwendung\PHP 7\php-win.exe" C:\Users\Jan\PhpstormProjects\censored\test.php
PHP Warning: DOMDocument::load(): Input is not proper UTF-8, indicate encoding !
Bytes: 0xE3 0xA4 0x63 0x68 in file:/C:/Users/Jan/PhpstormProjects/censored/data/gamesplanet.xml, line: 1423 in C:\Users\Jan\PhpstormProjects\censored\test.php on line 18
PHP Fatal error: Uncaught Error: Call to a member function getElementsByTagName() on null in C:\Users\Jan\PhpstormProjects\censored\test.php:23
Stack trace:
#0 C:\Users\Jan\PhpstormProjects\censored\test.php(86): countAd('data/gamesplane...')
#1 {main}
thrown in C:\Users\Jan\PhpstormProjects\censored\test.php on line 23
Process finished with exit code 255
In Zeile 1423 steht: W㥣hter Von Mittelerde
Und ohne dass ich die Values bearbeite, sprich bevor ich die 3 Mehoden hinzugefügt habe ging alles, die XMLs waren in UTF 8 Format und in Zeile 1423 stand: Wächter von Mittelerde.
Hat jemand eine Idee wie ich das beheben kann und woran das liegt?
Dieser Code verstaucht das:
Code:
function loadTitles($tagName, $path){
$dom = new DOMDocument('1.0', 'utf-8');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->load($path);
$marker = $dom->getElementsByTagName($tagName);
for ($i = $marker->length - 1; $i >= 0; $i--) {
$word = $marker->item($i)->textContent;
$escapedWord = escapWord($word);
$escapedWord = modifyWord($escapedWord);
$marker->item($i)->textContent = $escapedWord;
}
$dom->saveXML();
$dom->save($path);
}
function escapWord($string){
$replaceNothing = [":", ",", ";", "`", "#", "'", "´", "–", "!", "(", ")", ".", "@", "’", "+", "™"];
$replaceSpace = ["-", "–", "_", "/", ":"];
$delete = ["Steam", "Eu", "Key", "CD", "Gift", "Edition", "Pack", "Uplay", "Required", "Collection", "Origin", "HD", "Complete", "Digital", "Download", "EA", "Europa", "RPG", "Activated", "Access", "Code", "Limited", "Direct", "Bundle", "Special", "CDKEY", "GLOBAL", "EARLY", "ACCESS", "Card", "Cartel", "Player", "Trade", "DE", "GOG", "Multilanguage", "Multi", "Full", "Only", "UNCUT", "Cut", "Box", "Ps Vita", "VIP", "Rockstar", "Subscription"];
$string= str_replace($replaceNothing, '', $string);
$string= str_replace($replaceSpace, ' ', $string);
$string= preg_replace('~\b(?:' . implode('|', $delete) . ')\b~i', '', $string);
$string= str_replace("&", ' & ', $string);
$string= strtolower($string);
$string= ucwords($string);
$string= preg_replace('/\bAsia\b/i', 'ASIA', $string);
$string= preg_replace('/\buk\b/i', 'UK', $string);
$string= preg_replace('/\bAU\b/i', 'AU', $string);
$string= preg_replace('/\bXBOX\b/i', 'XBOX ', $string);
$string= preg_replace('/\bpc\b/i', 'PC', $string);
$string= preg_replace('/\bus\b/i', 'US', $string);
$string= preg_replace('/\bru\b/i', 'RUS', $string);
$string= preg_replace('/\bRUS\b/i', 'RUS', $string);
$string= preg_replace('/\bPS4\b/i', 'PS4', $string);
$string= preg_replace('/\bAddon\b/i', 'AddOn', $string);
$string= preg_replace('/\bPlay Station 4\b/i', 'PS4', $string);
$string= preg_replace('/\bPs4\b/i', 'PS4', $string);
$string= preg_replace('/\bPs3\b/i', 'PS3', $string);
$string= preg_replace('/\bPlayStation 4\b/i', 'PS4', $string);
$string= preg_replace('/\bPlay Station 3\b/i', 'PS3', $string);
$string= preg_replace('/\bPlayStation 3\b/i', 'PS3', $string);
$string= preg_replace('/\bPlayStation Network\b/i', 'PSN', $string);
$string= preg_replace('/\bPSN\b/i', 'PSN', $string);
$string= preg_replace('/\bXX\b/i', 'XX', $string);
$string= preg_replace('/\bXIX\b/i', 'XIX', $string);
$string= preg_replace('/\bXVIII\b/i', 'XVIII', $string);
$string= preg_replace('/\bXVII\b/i', 'XVII', $string);
$string= preg_replace('/\bXVI\b/i', 'XVI', $string);
$string= preg_replace('/\bXV\b/i', 'XV', $string);
$string= preg_replace('/\bXIV\b/i', 'XIV', $string);
$string= preg_replace('/\bXiii\b/i', 'XIII', $string);
$string= preg_replace('/\bXii\b/i', 'XII', $string);
$string= preg_replace('/\bXi\b/i', 'XI', $string);
$string= preg_replace('/\bIX\b/i', 'IX', $string);
$string= preg_replace('/\bVIII\b/i', 'VIII', $string);
$string= preg_replace('/\bVII\b/i', 'VII', $string);
$string= preg_replace('/\bVI\b/i', 'VI', $string);
$string= preg_replace('/\bV\b/i', 'V', $string);
$string= preg_replace('/\bIV\b/i', 'IV', $string);
$string= preg_replace('/\bIII\b/i', 'III', $string);
$string= preg_replace('/\bII\b/i', 'II', $string);
$string= preg_replace('/\bdlc\b/i', 'DLC', $string);
$string= trim(preg_replace('/\s\s+/', ' ', str_replace("\n", " ", $string)));
return $string;
}
function modifyWord($string){
if(strpos($string, "Counter Strike Offensive") !== false){
$newstring = explode("Offensive", $string);;
$newstring[0] = $newstring[0] . "Global Offensive";
$string = $newstring[0] . $newstring[1];
}
return $string;
}
Vielen Dank und MfG!