I'm trying to replace all td cells text to include link tag. Currently with the code below, the cells are being replaced but when I output the table, it literally just output the html code like so:
<a href="sdf" class="link">Some text</a>
Instead of a real physical HTML link. How do I actually replace a nodeValue with HTML tags? Thanks.
$DOM = new DOMDocument( );
@$DOM->loadHTML( $htmlTable );
$DOMXPath = new DOMXPath( $DOM );
$cellName = $DOMXPath->query('//td[contains(@class,"classA")]');
foreach( $cellName as $text ) {
$text->nodeValue = '<a href="sdf" class="link">' . htmlspecialchars( trim( $text->nodeValue ) ) . '</a>';
}
foreach( $cellName as &$text ) {and tell if it worked