Returning XML files inside a folder in PHP

0

I am using the following code to list and read the XML files in this folder. But how the listing returns me. and the .. my system returns error that it is not possible to access these files. Here are the codes used.

$pasta = $data[0].$data[1].$data[2]."_".$data_end[0].$data_end[1].$data_end[2];
$l_nfe = dir("xml/".$pasta);

while($arquivo = $l_nfe -> read()){
    simplexml_load_file("xml/".$pasta."/".$arquivo);
}

The string returns me "xml / 01042018_30042018 / .." could anyone help me how to list these xml files and loads them to display the content.

    
asked by anonymous 22.04.2018 / 19:30

1 answer

0

You have to add execution on these two directories in this way.

$pasta = $data[0].$data[1].$data[2]."_".$data_end[0].$data_end[1].$data_end[2];
$l_nfe = dir("xml/".$pasta);

while($arquivo = $l_nfe -> read()){
    if($arquivo !== "." && !$arquivo !== ".."){
       simplexml_load_file("xml/".$pasta."/".$arquivo);
    }
}
    
23.04.2018 / 16:24