SimpleXML来自另一个数组的多个数据

please, I have this code to import data from XML to database:

$a = glob('data/*/*.xml');

echo "import kategorie ...... ";
foreach ($a as $i) {
    $xml = simplexml_load_file("$i") or die ("Chyba: Nemuzu nacist soubor");

    foreach($xml->DocumentElement as $entry) {
        foreach ($entry->hotel as $dataHotel) {
            addCategory("$dataHotel->country", "$dataHotel->location", "$dataHotel->location2");
        }
        foreach ($entry->Popisy as $dataPopisy) {
            addHotel("$dataHotel->hotel", "$dataPopisy->doporuc");
        }
    }
}
echo "OK
"

I can not figure out how to do it - I need in function "addHotel" get data from "hotel" array and from "Popisy" array. So, I need to get from two at once.

Here is XML structure: http://pastebin.com/TNTpBijg and here http://fmnet.cz/HLS240.xml

Is this possilbe? Thank you very much!


Now I tried this:

$a = glob('data/*/*.xml');

echo "import kategorie ...... ";
foreach ($a as $i) {
    $xml = simplexml_load_file("$i") or die ("Chyba: Nemuzu nacist soubor");

    foreach($xml->DocumentElement as $entry) {
        foreach ($entry->hotel as $dataHotel) {
            //addCategory("$dataHotel->country", "$dataHotel->location", "$dataHotel->location2");
            foreach ($entry->Popisy as $dataPopisy) {
               //addHotel("$dataHotel->hotel", "$dataPopisy->doporuc");
                echo "$dataHotel->hotel";
                echo "
";
                echo "$dataPopisy->doporuc";
                echo "
";
            }
        }
    }
}
echo "OK
";

but output is only: import kategorie ...... OK

Yes, it is possible. You can do it by embedding the popisy loop inside the hotel loop or the other way round. Check the code below:

$a = glob('data/*/*.xml');

echo "import kategorie ...... ";
foreach ($a as $i) {
    $xml = simplexml_load_file("$i") or die ("Chyba: Nemuzu nacist soubor");

    foreach($xml->DocumentElement as $entry) {
        foreach ($entry->hotel as $dataHotel) {
            addCategory("$dataHotel->country", "$dataHotel->location", "$dataHotel->location2");
            foreach ($entry->Popisy as $dataPopisy) {
               addHotel("$dataHotel->hotel", "$dataPopisy->doporuc");
            }
        }
    }
}
echo "OK
"