php - Get div's HTML content via xpath -
this question has answer here:
- how innerhtml of domnode? 6 answers
i need support on following issue, have website want product descriptions via xpath. below example html of content:
<div id="description"> <span>some test</span> <img src="some src"> <p> content etc. </p> </div>
and use below code:
$result = $xpath->query('//div[@id="description"]');
but when i'm outputting result below line:
echo "<pre>".$result->item( 0 )->nodevalue."</pre>"; // there 1 element
what unformatted: "some testsome content etc." no spaces , other tags. know because xpath treats other tags nodes but...
i there way div's content html ?
hey did similar while , post helped me:
php domdocument / xpath: html-text , surrounded tags
it bit of overhead in code, mean if thought (like me) solved in 1 line different xpath query or something...
hope helped
Comments
Post a Comment