我正在尝试使用 XML 创建一个 zend_form,传递的 XML 包含所有标签,所以我不能使用htmlspecialchars()
,因为标签 < > 将被编码,这是我不想要的。是否有任何简单的方法来仅编码作为标签文本值的元素(标签之间的内容)?
$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);
保存在数据库中的 xml 的摘录:
<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>
来自研发的 & 需要更改&
为任何 > 或 < 等。
问候,