Q:

looping through inner articles xpath

I'm having trouble looping through this HTML in my xpath as below. The goal would be to loop through the article elements and then inside that once again the inner article elements. I think the problem is my inner query against the inner article elements
I have an HTML as follows:
 <div id="content">
   <article>
        <article>
           <div>
             <h2><a href="hrefvalue">Something Awesome</a></h2>
           </div>
        </article>
        <article>
           <div>
             <h2><a href="hrefvalue">Something Awesome</a></h2>
           </div>
        </article>
        <article>
           <div>
             <h2><a href="hrefvalue">Something Awesome</a></h2>
           </div>
        </article>
   </article>
   <article>
        <article>
           <div>
             <h2><a href="hrefvalue">Something Awesome2</a></h2>
           </div>
        </article>
        <article>
           <div>
             <h2><a href="hrefvalue">Something Awesome2</a></h2>
           </div>
        </article>
        <article>
           <div>
             <h2><a href="hrefvalue">Something Awesome2</a></h2>
           </div>
        </article>
   </article>
</div>

I have my xpath code as follows:
$articlesxpath = $xpath->query('//*[@id="content"]/article');
foreach($articlesxpath as $item){
  $items = $item->query('./article');
  foreach($items as $ix){
   var_dump($ix);
  }

}
As you can see, im trying to loop through the articles and then inside that element the inner article elements. The goal would be to get the information from the inner article elements
Not sure whats wrong with my code.

A:

To narrow xpath query pass second argument to query:
$articlesxpath = $xpath->query('//*[@id="content"]/article');
foreach($articlesxpath as $item){
    // search in $item node
    $items = $xpath->query('article', $item);
    foreach($items as $ix) {
        var_dump($ix->nodeValue);
    }
}

Or simply:
$articlesxpath = $xpath->query('//*[@id="content"]/article/article');
foreach($articlesxpath as $item){
    var_dump($item->nodeValue);
}

To get an href from a (and not from article) you should create a proper query:
$articlesxpath = $xpath->query('//*[@id="content"]/article/article/div/h2/a');
foreach($articlesxpath as $item){
    var_dump($item->getAttribute('href'));
}

And here's a manual, make sure you're familiar with it's text.

