I looked at your example code and I’m sorry but it seems like unrelated pieces. i.e.
What is “case”, part of a switch?
Where and how are you passing the XML to the DOM functions?
Where is the $cars that’s being assigned to $game and $amount?
Where are the $name and $colour variables used in the query being assigned?
Well, I got it to get and echo those values OK but I made so many changes I don’t know if any of this will help you.
Instead of writing file output to a file and using ->open() I put the XML into a string and used ->XML() for testing purposes.
Then I replaced the switch case with:
if ( ($xmlReader->name == ‘build’) && ($xmlReader->nodeType == 1) )
Because the SimpleXMLElement is being assigned to $product, there is no $cars object. The root node doesn’t come into play, and since the reader is already inside of the build node (because of the if conditional) $product->name and $product->colour work fine, though it doesn’t feel right assigning ->colour to $amount especially when the query uses $colour