问题描述
在PHP中使用XSLT时遇到一个奇怪的问题. XSL文件中的所有br标签都将转换为< br></br>.即br标签的打开和关闭.
I am facing strange issue while using XSLT in PHP. All the br tags in XSL files are getting converting into <br></br> i.e. opening and closing of br tag.
此转换在Google Chrome浏览器中造成UI问题. Chrome正在转换</br>进入另一个< br>标签,因此UI变得混乱不清.
This conversion is creating UI issues in Google Chrome browser. Chrome is converting </br> into another <br> tag hence UI is getting gabbled.
请尽快帮助我.....
Please help me ASAP.....
推荐答案
我在 PHP手册站点上找到了我的问题的答案.网址: http://php.net/manual/en/xsltprocessor.transformtoxml.php
I found the answer to my question on PHP manual site. URL: http://php.net/manual/en/xsltprocessor.transformtoxml.php
它在用户评论中,以下是相同的评论:
$ domTranObj = $ xslProcessor-> transformToDoc($ domXmlObj);
$domTranObj = $xslProcessor->transformToDoc($domXmlObj);
$ domHtmlText = $ domTranObj-> saveHTML();
$domHtmlText = $domTranObj->saveHTML();
请修复< meta>表示有效的XHTML,但不能正确结束空节点,如< br/>这样的输出:< br></br>
Do fix the <meta> for valid XHTML but do not correctly end empty node like <br /> which ouput like this : <br></br>
某些浏览器将其记为2个不同的< br/> ...
Some browser note this as 2 different <br /> ...
要解决此问题
$ domTranObj = $ xslProcessor-> transformToDoc($ domXmlObj);
$domTranObj = $xslProcessor->transformToDoc($domXmlObj);
$ domHtmlText = $ domTranObj-> saveXML();
$domHtmlText = $domTranObj->saveXML();
这篇关于PHP XSLT将BR标签转换为< br></br>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!