Xpath Nodevalue/textcontent Unable To See
Tag
HTML is as follows: ABCDEF However, both nodeValue and textContent attributes show 'ABCDEF' as the value. Any way to show or parse the
Solution 1:
Maybe this'll help you: DOMNode::C14N
It'll return the HTML of the node.
<?php$a = '<a href="#">ABC<BR>DEF</a>';
$doc = new DOMDocument();
@$doc->loadHTML($a);
$finder = new DomXPath($doc);
$nodes = $finder->query("//a");
foreach ($nodesas$node) {
var_dump($node->c14n());
}
Solution 2:
I know you have already solved your problem, but I wanted to add a more direct way of solving it...
$a = '<a href="#">ABC<BR>DEF</a>';
$doc = new DOMDocument();
$doc->loadHTML($a);
$xp = new DomXPath($doc);
$nodes = $xp->query("//a/node()");
$text = '';
foreach ($nodesas$node) {
$text .= $doc->saveHTML($node);
}
echo$text;
Outputs...
ABC<br>DEF
Post a Comment for "Xpath Nodevalue/textcontent Unable To See
Tag"