I have a xml file with structure like this:
<categories>
<category>
<id></id>
<name></name>
</category>
...
</categories>
<products>
<product>
<id></id>
<name></name>
</product>
...
</products>
<params>
<param>
<id></id>
<name></name>
</param>
...
</params>
<product_params>
<product_param>
<param_id></param_id>
<product_id></product_id>
</product_param>
...
</product_params>
How do I display product nodes, right category (that matches id) and all params for that product?
I tried doing something like this:
$xml = simplexml_load_file('file.xml');
$products = $xml->products;
$product_params = $xml->product_params->product_param;
foreach ($products->product as $product) {
echo '<p>'.$product->name.'</p>';
for($i=0; $i < count($product_params) ;$i++) {
if($product->id == $product_params[$i]->product_id) {
}
}
}
The file is too big and script crashes. Plus with my "solution" I would need at least one more loop nested in there.