I'm trying to create a loop in PHP to get information from the XML files in a directory.
<?php
$files = scandir('articles/');
foreach($files as $file) {
$article = simplexml_load_file($file);
$article_name = $article->LV_ARTICLES_DESCRIPTIONANDMEASURE->LV_ARTICLES_LANG_NL;
$article_specification = $article->LV_ARTICLES_SPECIFICATION->LV_ARTICLES_LANG_NL;
$article_price_incl = number_format((float)$article->LV_ARTICLES_PRICE_SHOW, 2, '.', '');
$article_shortinfo = $article->LV_ARTICLES_SHORTMEMO->LV_ARTICLES_LANG_NL;
$article_image = $article->LV_ARTICLES_PICTUREZOOM;
?>
<div clas="name" style="font-size:22px; width:100%; margin:12px 0px;"><ul style="list-style:none; width:400px; margin:0 auto;"><li style="font-weight:bold;">Naam:</li><li><?php echo $article_name;?></li></ul></div>
<div clas="specs" style="font-size:22px; width:100%; background-color:#f7f7f7; margin:12px 0px;"><ul style="list-style:none; width:400px; margin:0 auto;"><li style="font-weight:bold;">Specificaties:</li><li><?php echo $article_specification;?></li></ul></div>
<div clas="name" style="font-size:22px; width:100%; margin:12px 0px;"><ul style="list-style:none; width:400px; margin:0 auto;"><li style="font-weight:bold;">Prijs inclusief BTW:</li><li>€<?php echo $article_price_incl;?></li></ul></div>
<div clas="specs" style="font-size:22px; width:100%; background-color:#f7f7f7; margin:12px 0px;"><ul style="list-style:none; width:400px; margin:0 auto;"><li style="font-weight:bold;">Omschrijving:</li><li><?php echo $article_shortinfo;?></li></ul></div>
<div style="text-align:center;"><img src="images/<?php echo $article_image; ?>"></div>
<?php
}
?>
<?xml version="1.0" encoding="UTF-8"?>
<Logivert>
<LV_ARTICLES_DESCRIPTIONANDMEASURE>
<LV_ARTICLES_LANG_NL><![CDATA[Recoverage Intensive Moisture Balance]]></LV_ARTICLES_LANG_NL>
</LV_ARTICLES_DESCRIPTIONANDMEASURE>
<LV_ARTICLES_SPECIFICATION>
<LV_ARTICLES_LANG_NL><![CDATA[Heerlijk]]></LV_ARTICLES_LANG_NL>
</LV_ARTICLES_SPECIFICATION>
<LV_ARTICLES_PRICE_CURRNAME>
<LV_ARTICLES_LANG_NL><![CDATA[€]]></LV_ARTICLES_LANG_NL>
</LV_ARTICLES_PRICE_CURRNAME>
<LV_ARTICLES_PRICE_SHOW>39.500000</LV_ARTICLES_PRICE_SHOW>
<LV_ARTICLES_SHORTMEMO>
<LV_ARTICLES_LANG_NL><![CDATA[ <p><div>Deze oil free moisturizer is een heerlijke, lichte dagelijkse moisturizer, voor de vette, gevoelige en gecombineerde huid. Heeft een drievoudige werking, voedt, beschermt en vertraagt het verouderingsproces.</div> <div><br /></div> <div>De lichte structuur wordt snel opgenomen door de huid. Voor dagelijks gebruik. </div> <div><br /></div> <div>Previlient™, hyaluronzuur en power antioxidanten</div> <div><br /></div> <div>Alle producten binnen de nieuwe Bio Ac ve by Mineral Care RECOVERAGE™-lijn bevatten als key-ingrediënt Previlient™. Dit is een cocktail van de natuurlijke ingredienten pure Ribose en Artemia-extract. Deze combinatie stimuleert een gezonde celvernieuwing en heeft een krachtige anti-ageing effect. De toegvoegde hyaluronzuur, moisturizers en Dode Zeemineralen versterken en ondersteunen de natuurlijke vochtbalans van de huid. Een synergetische mix van de power antioxidanten Vitamine C, E en Groene Thee-extract beschermen de huid zowel van binnenuit als van buitenaf. </div> </p>]]></LV_ARTICLES_LANG_NL>
</LV_ARTICLES_SHORTMEMO>
<LV_ARTICLES_LONGMEMO>
<LV_ARTICLES_LANG_NL><![CDATA[]]></LV_ARTICLES_LANG_NL>
</LV_ARTICLES_LONGMEMO>
<LV_ARTICLES_PICTUREZOOM>zoom/m_692.jpg</LV_ARTICLES_PICTUREZOOM>
</logivert>
When I run the page it is still blank. If I echo the $file
variable the output is: ...article_1.xmlarticle_2.xmlarticle_3.xml etc.
What can I do? What's wrong with the loop?