php - Get div's HTML content via xpath -


this question has answer here:

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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -