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 - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -