Mark text in HTML

后端 未结 5 645
迷失自我
迷失自我 2021-01-14 03:39

I have some plain text and html. I need to create a PHP method that will return the same html, but with before any instances of th

5条回答
  •  醉话见心
    2021-01-14 04:25

    XSL is the right tool for this kind of job. You can do something like this,

    
    
        My Name Is Josh!!!
    
    
        

    my name is josh

    my name is josh
    my name is Josh. EOT; $temp = << EOT; $xml = new DOMDocument; $xml->loadXML($oldXml); $xsl = new DOMDocument; $xsl->loadXML($temp); $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); // attach the xsl rules $newXml = $proc->transformToXML($xml); echo $newXml;

    The HTML must be well-formatted XHTML for this work.

提交回复
热议问题