Same as before!
PHP Code:
foreach($xml->xpath('//PRODUCT/@ITEM') as $productitemid){
foreach($xml->CREATED->CATEGORY->PRODUCT as $product) {
mysql_query("INSERT INTO products (products_id,products_model)
VALUES ('$productitemid','$product->MODEL')")
}
}
But, are you sure you need to nest two foreach()? To know that I would have to know the structure of the array or arrays you are working with.
If they don't need to be nested, this might work
PHP Code:
foreach($xml->xpath('//PRODUCT/@ITEM') as $productitemid){
mysql_query("INSERT INTO products (products_id,products_model)
VALUES ('$productitemid','$xml->CREATED->CATEGORY->PRODUCT')")
}
Or you might need
PHP Code:
foreach($xml->xpath('//PRODUCT/@ITEM') as $key=>$productitemid){
mysql_query("INSERT INTO products (products_id,products_model)
VALUES ('$productitemid',
'$xml->xpath('//PRODUCT/@ITEM')[$key]['something']')")
}
It depend on how the array()s are organized.
Bookmarks