I try to parse an XML file, the code I have only works when I add the XML directly in the PHP code, but I need to get it working with an external file.
I tried many ways to get it working, but without success.
UPD. No advises were helpful, I found solution by myself.
Thank you for all who try to help me.
<?php
$url = "link to file";
$domSrc = file_get_contents($url);
$dom = new DomDocument();
$dom->loadXML( $domSrc );
while(is_object($finance = $dom->getElementsByTagName("item")->item($i)))
{
foreach($finance->childNodes as $nodename)
{
if($nodename->nodeName=='id')
{
echo "<p>$nodename->nodeValue</p>";
}
}
}
$i++;
}
?>