dom - DomXPath php omitting html elements -
this question has answer here:
- how innerhtml of domnode? 6 answers
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
Post a Comment