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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -