dom - DomXPath php omitting html elements -


this question has answer here:

i'm trying keep parts of html elements inside dom loaded domdocument , curl.

problem when xpath query , retireve nodevalue omits html elements.

below code. there way retrieve html particular node?

$location = $xpath->query("//div[@id='location']/label"); echo $location->item(0)->nodevalue."<br>"; 

$dom = new domdocument(); $dom->loadhtml('<html><div id="location"><label><h1>hello <b>world</b></h1></label></div></html>'); $xpath = new domxpath($dom); $location = $xpath->query("//div[@id='location']/label/*");   var_dump($dom->savexml($location->item(0))); 

output:

string(27) "<h1>hello <b>world</b></h1>" 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -