页面含html文本提交处理
XML code1 | <!--Code highlighting produced by Actipro CodeHighlighter (freeware)http:
|
登入後複製
以上xml里面的正确格式
现在如果要修改的话,我会先取出aa节点下面的值,然后直接提交就报错。
我用htmlspecialchars编码过,然后提交给xml节点后,虽然不报错,但是显示成下面错误的这样。
XML code1 | <!--Code highlighting produced by Actipro CodeHighlighter (freeware)http:
|
登入後複製
请问要提交含html标记的值给xml节点需要怎样处理下?
------解决方案--------------------CDATA 中的内容不需要转义!转义反而错了
------解决方案--------------------XML code1 | <aa url= "www.xxx.com" > <font size= "13" ><a href= "www.xxx.com?x=s&f=3" target= "_blank" >常 见 问 答1</a></font><br><br> <font size= "13" ><a href= "www.xxx.com?x=s&f=3" target= "_blank" >常 见 问 答2</a></font><br><br> <font size= "13" ><a href= "www.xxx.com?x=s&f=3" target= "_blank" >常 见 问 答3</a></font><br><br> </aa><br><font color= "#e78608" >------解决方案--------------------</font><br>之后不要用htmlspecialchars编码<br><font color= "#e78608" >------解决方案--------------------</font><br>php.ini中 magic_quotes_gpc()函数是打开的么?自动给引号转义了。。<br><font color= "#e78608" >------解决方案--------------------</font><br>用XmlWriter写CDATA数据<br><font color= "#e78608" >------解决方案--------------------</font><br>顺便给你粘过来.
|
登入後複製
PHP code1 2 3 4 5 6 | $str = <url> </url><url> </url>XML; $xml = simplexml_load_string( $str , 'simpleXMLElement' ,LIBXML_NOCDATA);header( 'Content-type: application/xml' ); $xw = new XMLWriter(); $xw ->openMemory(); $xw ->startDocument( '1.0' , 'utf-8' ); $xw ->startElement( 'root' ); foreach ( $xml ->url as $item ){
</div>
|
登入後複製