I trying to make a simple matrix for parsing XML files with quite different tags, i doing it with simple table viz. screen, table has primary and foreign atribute, in primary are main tag in foreign are quite similiar tags, so basicly i have code, but it parse just first record, like it was limited by while loop in foreach, so it behave like foreach run trough just once...
$i = -1;
$result = array();
foreach($souborXML->SHOPITEM as $zam)
{
$i++;
while(list($id,$primary,$foreign)=mysql_fetch_row($q_matrix))
{
$result[$i][$primary] = htmlspecialchars($zam->$primary);
if(empty($result[$i][$primary]))
{
$array_category = explode( ',', $foreign );
for($iterator=0;$iterator<count($array_category);$iterator++)
{
$result[$i][$primary] = htmlspecialchars($zam->$array_category[$iterator]);
If(!empty($result[$i][$primary]))
{
$result[$i][$primary] = htmlspecialchars($zam->$array_category[$iterator]);
}
}
if(empty($result[$i][$primary]))
{
$result[$i][$primary] = 'Tag nebyl nalezen, přidejte nový cizí tag pro kategorie!';
}
}
}
}
var_dump($result);
Table structure: here
XML Structure: here
Current output:
array (size=1)
0 =>
array (size=2)
'PRODUCT' => string 'Bezešvá těhotenská košilka - antibakteriální' (length=51)
'CATEGORY' => string 'Oblečení a obuv / Oblečení dámské / spodní prádlo / Těhotenské a mateřské prádlo' (length=93)