How to iterate with PHP through HTML DOM with xPath -


i'm looking way step in , out domnodelist. when search hit specific element next element located @ level. in detail:

<tr>   <td>     <div class="category">       <a>headline:</a>     </div>   </td> </tr> <tr>   <td>     <div class="cdata">       <span>article title</span>     </div>   </td> </tr> 

my work far:

$xpath = new domxpath($dom);  $nodes = $xpath->query("//tr/td/div[@class='category']/a");  header("content-type: text/plain");  foreach ($nodes $i => $node) {   echo "node($i): " . ltrim($node->nodevalue) . "\n";   if (ltrim($node->nodevalue) == 'headline:')   {     // how can fetch nodevalue in next tr     echo "parent: " . $node->parentnode->parentnode->parentnode->nodevalue . "\n";   } } 

so until haven't figured out how iterate 3 times next "tr" , there go down next div class ".cdata".


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -