I have a mySQL table with fields containing copy that’s being turned into XML. Some of the copy in the mySQL fields has bold tags around the words:
<b>This will be bold</b>, this won't be.
However, when I come to build my XML document using XMLwriter, the copy ends up looking like this:
<b>This will be bold</b>, this won't be
Can anyone advise me on how I can avoid character encoding for these tags?
I am guessing your code needs to use
XMLWriter::writeRawinstead ofXMLWriter::text.Note that this will only be a good solution if you are confident the content in the database will be proper XML. Otherwise, you will need to first run that content through a DOM parser like
DOMDocument::loadXMLwith theDOMDocument::recoverflag set, and then export the content withDOMDocument::saveXMLand pass it toXMLWriter::writeRaw.