Pass XML Path into Function Doesn't Return Value

anonymousx

New Member
I have the following PHP function that takes an XML Path after the -> for my SimpleXML.\[code\]function parseRecipeData($xmlPath) { global $db_recipe_type; global $db_recipe_filename; global $xml; $xml = simplexml_load_file($db_recipe_filename); // var_dump($xml); // Get data from XML Field $requestedInfo = $xml->$xmlPath; //var_dump($requestedInfo); return $requestedInfo;}\[/code\]My problem is that PHP line #1 returns nothing, while PHP line #2 returns the XML Value. Note that \[code\]$recipeSize = "batch->attributes()->quantity";\[/code\] is defined at the top of my application and should be a global scope. My XML tree is below the rest of this code.1: \[code\]<?php echo parseRecipeData($recipeSize); ?>\[/code\]2: \[code\]<?php echo $xml->batch->attributes()->quantity; ?>\[/code\]XML Structure\[code\]<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE recipe><recipe> <batch quantity="2.13 gal"/></recipe>\[/code\]Can anyone see why one PHP line would return a function and wouldn't considering they should resolve to the same code?
 
Back
Top