php - Xpath nodeValue/textContent unable to see <BR> tag -


html follows:

<a href="#">abc<br>def</a> 

however, both nodevalue , textcontent attributes show "abcdef" value.

any way show or parse <br>?

maybe this'll you: domnode::c14n

it'll return html of node.

<?php $a = '<a href="#">abc<br>def</a>'; $doc = new domdocument(); @$doc->loadhtml($a); $finder = new domxpath($doc); $nodes = $finder->query("//a"); foreach ($nodes $node) {     var_dump($node->c14n()); } 

demo


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -