Hey folks,
I have XML files that I need to correctly tab so that they're human readable. The code I've been trying to get to work is here:
<?php
$errorFile = "myFile.xml";
$fileReader = fopen($errorFile, "r");
$fileData = fread($fileReader, filesize($errorFile));
$fileData = preg_replace("<[a-z]+>","<[a-z]+>\n",$fileData);
echo($fileData . "\n\n\n");
?>
You can test this with pretty much any xml file that is all on one line. As you can see my regular expression isn't working and I'm not sure why (since I'm new to regEx). Any suggestions? My basic goal is to say:
1) "If you find '< /[anything here] >' then replace it with '< /[anything here] >\n'."
2) "If you find '< [anything here] />' then replace it with '< [anything here] />\n'."
Any help would be much appreciated.
Thanks,