MySQL Forums
Forum List  »  Connector/Node.js

How to get a xml compliant result fields with a mysql query?
Posted by: Aitor Hernández
Date: April 06, 2009 01:48AM

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 ( &lt; ,&gt; ,&amp; ... ) 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.

Options: ReplyQuote


Subject
Written By
Posted
How to get a xml compliant result fields with a mysql query?
April 06, 2009 01:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.