Created
September 13, 2013 00:54
-
-
Save cmbirk/6545739 to your computer and use it in GitHub Desktop.
PHP script to strip entities from XML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$unconvertedEntity = array( | |
'%', | |
' ', | |
'_' | |
); | |
$convertedChar = array( | |
'%', | |
' ', | |
'_' | |
); | |
$filename = $argv[1]; | |
$xml = file_get_contents($filename); | |
$xml = html_entity_decode($xml); | |
$xml = htmlspecialchars_decode($xml, ENT_HTML5); | |
$xml = str_replace($unconvertedEntity, $convertedChar, $xml); | |
$xml = str_replace('&', '&', $xml); | |
file_put_contents('stripped/'.$filename, $xml); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment