I have a system that writes a XML file.
The problem is that I cannot have in the XML file this symbol &
I need to replace this symbol wherever it is find in the code with &
The problem is I have a LOT of strings, and I do not want to apply a function that will replace that symbol for EVERY SINGLE string I have.
This is an example:
$stringData ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$stringData .="<ingrooves_import xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:schemaLocation=\"http://schemas.ingrooves.com/INgrooves/INgroovesImport_1_0.xsd\" schema_version=\"1\" schema_revision=\"0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.ingrooves.com/INgrooves/INgroovesImport_1_0.xsd\">\n";
$stringData .= "<album>\n";
$stringData .= "<title>".$albumTitle."</title>\n";
$stringData .= "<label_reference>LA0001</label_reference>\n";
$stringData .= "<performer>".$MainArtist."</performer>\n";
$stringData .= "<catalog_number>".$CatalogueNumber."</catalog_number>\n";
$stringData .= "<upc>".$UPC_EAN_JAN."</upc>\n";
$stringData .= "<release_date>".$releaseDate."</release_date>\n";
$stringData .= "<copyright>".$DigiDistYear."</copyright>\n";
And I have many more of $stringData in my code. So you can understand I do not want to apply for every $stringData a code that will replace that symbol.
I want to find a way to tell to the code, that for any $stringData variable, and for any content this $stringData will encounter, then it must replace & with &
Is there a way of doing it?
In few words, the code should do so:
For every content you are going to encounter inside the variable $stringData, from now on, you should change & with & everytime you encounter this symbol.
Please help me!
Thanks
At the end of the script, when you finished adding code to the string, add the following:
You can do also with regular expressions but this will work aswell 🙂