need to parse a large XML document and add the values into a SQL db. I'd like to store all of the key/value pairs in a sql db to simplify my PHP code. Not all of the nodes are present in all of the XML records, so want to iterate through the DB values, i.e. classification->pn, then see if the node exists, then add the value to the SQL insert. Can't get it to work:
So instead of:
foreach($xmldata->children() as $node) {
if(isset($node->classification->pn)) {
...
}
}
I want to do:
foreach($xmldata->children() as $node) {
if(isset($node->$sqlrow['childnodename'])) {
...
}
}
where $sqlrow['childnodename'] = "classification->pn"
as stored in my sql table.
Tried treating it like a dynamic variable, using $$childnodename
, etc., but nothing seems to work.