<?xml version="1.0" encoding="ISO-8859-1" ?>
<pages>
<page>
<title>Home</title>
<content>Lorem Ipsum</content>
</page>
<page>
<title>Pictures</title>
<content>Lorem Ipsum</content>
</page>
<page>
<title>Information</title>
<content>Lorem Ipsum</content>
</page>
</pages>
My XML
$url = "xml->build.xml";
$xml = simplexml_load_file($url);
$i = 1;
foreach($xml->page as $page) {
echo "<strong>Page ".$i.":</strong> ".$page->title."<br/>";
$i++;
}
My PHP
I’m getting:
Warning: simplexml_load_file(): I/O warning : failed to load external entity “xml->build.xml”
Just from that simple script! Any Ideas? 🙂
Updated, this is the exact XML file
<?xml version="1.0" encoding="ISO-8859-1" ?>
<pages>
<page>
<title>Home</title>
<content>Lorem Ipsum</content>
</page>
<page>
<title>Pictures</title>
<content>Lorem Ipsum</content>
</page>
<page>
<title>Information</title>
<content>Lorem Ipsum</content>
</page>
</pages>
<css>
<css-tag>
<title>background-color</title>
<value>#FFF</value>
</css-tag>
</css>
<layout>1</layout>
That’s happening because you’re trying to read a file that is not there. If your file is named
build.xmland is stored in the same directory as the PHP script, replace:with: