I am relatively new to programming but with the help of Google i'm getting on well.
I need some help with a program I am writing and I have a small problem with the coding. It does everything I want it to except I can't work out 1 part.
What I am trying to achieve is an XML file with a line that looks like:
<Entry Line=' Play "Mains_Fail"' />
However the code I am using in Delphi:
Parameter.AddChild('Entry').Attributes['line'] := ' Play "Mains_Fail" ';
Produces the following line in XML:
<Entry Line=" Play "Mains_Fail"" />
This doesn't work on the system reading the file as i need the apostrophe in the XML output not quotes.
With what code can I produce apostrophe?
<Entry Line=" Play "Mains_Fail"" />
This is perfectly correct, and is semantically identical to
<Entry Line=' Play "Mains_Fail"' />
or
<Entry Line=' Play "Mains_Fail"' />
Attribute values are quoted, either single or double quotes. If you use single quotes, then any single quote characters in the value must be escaped, with '
. If you use double quotes, then any double quote characters in the value must be escaped, with "
.
The bottom line is that you are producing XML, and any XML parser will read all three of the above snippets identically. If you have a system that won't read one of these snippets then you should replace the parser with an actual XML parser.