I've come across this problem when automatically generating XML files as well. We have a test harness at work called CPPUNIT that has an option to output results to an xml file. This ASSERTS or error messages are whatever the developer defines in the code, but they often won't think about how that affects XML. XML has these special character restrictions as well (just like HTML for this blog) and if it finds any of them in the XML file, the file becomes invalid. We had to do a search and replace of these special characters in order to ensure our XML files don't become invalid.
Anyway, on to the answer. If you need to place <, >, &, ", or ', then use the following table. Just type in the weird character string with semi-colon at end wherever you want the special character to appear in your blog post or XML file.
< ....... <
> ....... >
& ....... &
" ....... "
' ....... '
There are much more for HTML, but the above are what I find to be the most common and all that you need.
No comments:
Post a Comment