Hello people,
Where do I begin… a XML file needs to go into a database. Therefore I want to make a config array containing the mapping between XML nodes and table-columns of one table.
$maps = array(
// 'node-name'=>'column-name'
'prod_id'=>'supplier_product_id',
'description'=>'product_description',
);
$xml=simplexml_load_file($file);
//just a test
foreach ($maps as $node => $col){
echo 'node ' . $xml->$node . ' is mapped to: ' . $col; //this works
}
There is information I need to put in this (same) table, from a subnode. So I was thinking of putting subnodes in a nested array like this:
$maps = array(
// 'node-name'=>'column-name'
'prod_id'=>'supplier_product_id',
'description'=>'product_description',
// to access $xml->node->subnode;
'category'=>array(
'id'=>'category_id',
),
);
But now I get confused, how can I use the nested array to make an path to the node like this:
$xml->category->id