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\n" 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 "\n"; echo "$dataPopisy->doporuc"; echo "\n"; } } } } echo "OK\n"; but output is only: import kategorie ...... OK
hotelgoes with whichPopisy? Can you show us a sample of the data, to see the format?