I am kinda new in xml parsing, I am trying to figure out what is wrong with this piece of code why is it refusing to display any result?
//php code
$file=file_get_contents("http://".$_SERVER["HTTP_HOST"]."/sitemap.xml");
$dom = new DOMDocument();
$dom->loadXML($file);
$xmlPath = new DOMXPath($dom);
$arrNodes = $xmlPath->query('//loc');
foreach($arrNodes as $arrNode){
echo $arrNode->nodeValue;
}
//sitemap.xml
<url>
<loc>http://calculosophia.com/</loc>
</url>
<url>
<loc>http://calculosophia.com/finance/compound-interest-calculator</loc>
</url>
I can see that the file is getting retrieved successfully but when var dumping $arrNodes it gives me object(DOMNodeList)[170] I dunno what to do further
$arrNode->item(0)->nodeValueto$arrNode->nodeValuevar_dump($arrNode)inside the loop?