paulus4605 Posted September 15, 2011 Share Posted September 15, 2011 The goal of this excercise is to find "invalid characters" in a given file the characters that I am refering to are éèàëöï&ê I have this code at the moment that checks if the structure of the file is a valid xml file However the part where I want to check the content of the same xml file for the above mentioned characters I don't get any errors dispite the fact that I put these characters in the file <?php header( 'Content-Type: text/html; charset=UTF-8;' ); ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); $xdoc = new DomDocument; $xmlfile = 'Testpayment.xml'; $xmlschema = './xmlschemes/pain.001.001.02.xsd'; //Load the xml document in the DOMDocument object $xdoc->Load($xmlfile); //Validate the XML file against the schema if ($xdoc->schemaValidate($xmlschema)) { print "$xmlfile is valid.\n"; } else { print "$xmlfile is invalid.\n"; } echo '<pre>'; $xmlfile = array(); foreach ( $xmlfile as $string ) { if (preg_match( '#^[a-z0-9/?:.( ),\' +-]*$#i', $string ) ) { echo 'GOED'; } else { echo 'FOUT'; } echo ' ' . $string . PHP_EOL; } echo '</pre>'; ?> What am I doing wrong here? Link to comment https://forums.phpfreaks.com/topic/247172-how-to-find-specific-characters-in-file/ Share on other sites More sharing options...
paulus4605 Posted September 15, 2011 Author Share Posted September 15, 2011 any help would be very much appreciated Link to comment https://forums.phpfreaks.com/topic/247172-how-to-find-specific-characters-in-file/#findComment-1269516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.