Reputation: 17
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?
Upvotes: 1
Views: 339
Reputation: 17487
I am guessing your code needs to use XMLWriter::writeRaw
instead of XMLWriter::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::loadXML
with the DOMDocument::recover
flag set, and then export the content with DOMDocument::saveXML
and pass it to XMLWriter::writeRaw
.
Upvotes: 2
Reputation: 12826
Pass your copy through html_entity_decode()
, like this:
echo html_entity_decode("<b>This will be bold</b>, this won't be");
Upvotes: 0