How to get a xml compliant result fields with a mysql query?
I am trying to obtain xml directly with an mysql query like this:
select GROUP_CONCAT( DISTINCT '<product name="',product_name,'" total="',total,'" percent="',total_percent,'" ></product>' SEPARATOR '\n') as xml
FROM ( select QUOTE(UPPER(trim(nombreproducto))) as product_name,COUNT(*) as total , COUNT(*)* indice_percent as total_percent
from formularios_ibercaja.contratacion_general, (SELECT 100/COUNT(*) as indice_percent FROM formularios_ibercaja.contratacion_general where nombreproducto != "") as L0
where nombreproducto != ""
group by nombreproducto
order by total DESC ) as L1
But the result fields contains non compliant xml chars like (<,>, &...), this will generate an invalid xml text, are there any way to obtain the content of the fields with xml entities ( < ,> ,& ... ) instead of (<,>,&,...) , I am trying using regular expresions but that doesn't look the best solution.
I can't use CDATA because many fields are parameters
Any suggestions
Any a ideas.
Tnks in adv.