1

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)

1 Answers1

0

Actually i found a possible solution, its really simple, everything what i need its check the tree, i take just one record and test all possible matched tags then i will take whole file with already known tags... later i will add code sample...

  • 1
    Please do post your solution. Also, don't forget to accept your answer as the solution (press the green check mark) when it is eligible. – Patrick M Mar 29 '14 at 22:02