I have a XML file like this
<Articles>
<Article>
<ArticleTitle>
First Book
</ArticleTitle>
</Article>
<Article>
<ArticleTitle>
Second Book
</ArticleTitle>
</Article>
And using this type of php script to retrieve the contents of ArticleTitle in an iterative fashion
foreach ($xml->Article as $Article){
$title = $Article->xpath('//ArticleTitle');
echo $title[0];
}
But this displays
First Book
First Book
Instead of
First Book
Second Book
I was assuming that when the foreach ($xml->Article as $Article) starts it will grab each Article node and then I can access the contents of that node but this is not what is happening. What am I doing wrong?