Escape XML from database for output

ardit_620

New Member
I'm trying to create a zend_form using XML, the passed XML includes all the tags so I can't use \[code\]htmlspecialchars()\[/code\] because the tag < > would be encoded which I dont want. Is there any easy way to encode just elements that are text values of the tags (the content between tags)?\[code\]$xml = sprintf('<?xml version="1.0" encoding="UTF-8"?><form><localhost><formmanager><formpage><elements>%s</elements></formpage></formmanager></localhost></form>', $r['form_template']);$config = new Zend_Config_Xml($xml, 'localhost');$form = new Zend_Form($config->formmanager->$formName);\[/code\]An extract of the xml saved on the DB : \[code\]<questionTechnicalServices><type>MultiCheckbox</type><options><class>rule2 standard basic2 starter business spotlight</class><label>Technical Services</label><multioptions><item-ContractLaboratoryandtestingServices>Contract Laboratory and testing Services</item-ContractLaboratoryandtestingServices><item-ContractRDDesignandEngineering>Contract R&D, Design and Engineering</item-ContractRDDesignandEngineering><item-ContractSterilization>Contract Sterilization</item-ContractSterilization><item-CoilingRespoolingWinding>Coiling/Respooling/Winding</item-CoilingRespoolingWinding><item-OthersTechnicalServices>Others</item-OthersTechnicalServices></multioptions></options></questionTechnicalServices>\[/code\]The & from R&D, needs to be changed to \[code\]&\[/code\] as would any > or < etc.Regards,
 
Back
Top