Click to See Complete Forum and Search --> : Using html entities in XML


tehashman
01-07-2009, 10:20 AM
Hi there I have an xml that contains data pulled from a database. sometimes this data may contain html entities such as &, £ < and > but they will be encoded into their html quivalents before being put into the xml.

so an xml node may look like this:
<data>hello &amp; Good Bye</data>

the only problem is that both IE and FF XML parsers throw an error resulting in my page not working.

how am i able to add these entities into the xml?

Thanks

TehAshMan

Charles
01-07-2009, 10:56 AM
All XML parsers should catch that error. You have two options and I've been known to use both. Either you declare the entities in your XML's prolog or you do your entity substitution between the DB and your client. PHP has a function that will do this for you, if that's what you are using now.