how to form a path to XML subnodes with a multidimensional array

r3lay

New Member
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.\[code\]$maps = array( // 'node-name'=>'column-name' 'prod_id'=>'supplier_product_id', 'description'=>'product_description',);$xml=simplexml_load_file($file);//just a testforeach ($maps as $node => $col){ echo 'node ' . $xml->$node . ' is mapped to: ' . $col; //this works}\[/code\]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:\[code\]$maps = array( // 'node-name'=>'column-name' 'prod_id'=>'supplier_product_id', 'description'=>'product_description', // to access $xml->node->subnode; 'category'=>array( 'id'=>'category_id', ),);\[/code\]But now I get confused, how can I use the nested array to make an path to the node like this: \[code\]$xml->category->id\[/code\]I am a newbee in PHP and hopefully some help will keep me on the road again. All help is welcome, thank you in advance.
 
Back
Top