I’m writing a xml to text file script with PHP’s xml parser. I delimit attributes with @ signs and data with | symbols, what I’ve noticed is when I open the text file is that symbols are seen as their own data.
i.e. <equation valid="yes">For this theorem assume X < Y and Z & A = 0</equation>
should have output @yes@ |For this theorem assume X < Y and Z & A = 0|
but instead I have @yes@ |For this theorem assume X| |<| |Y| and Z | |&| | A = 0|
so what I believe is going on is that any symbols that rely on &[a-z]+; or &[0-9]+; gets treated as different data between the two tags. I tried preg_replace("/&([a-z]+);/","\1",$data) and the same for numbers to just have the letters/numbers there for me to format later but that didn’t seem to do anything. How can I get xml parser to recognize those symbols as part of the data?
Edit1: I’ve just now also tried replacing all & with \& but that didn’t do anything either, I just get backslashes before my data delimiter.
I believe you are asking about special characters in a string?
If so you need to use the ascii equivilent, i.e.