I've got the following block of code:
[xml]$xml = @"
<response>
<num>2</num>
<time>7</time>
</response>
"@
$VARS = New-Object -TypeName PSObject `
-Property @{root = "response"
num = "response.num"}
$xml.($VARS.root) # test 1
$xml.($VARS.num) # test 2
Test one returns the two elements num and time. Test two does not return anything (because there is no such element 'response.num' in the xml). Is it possible to get powershell to evaluate a String as a variable? So as above, if I have a string 'variable.property.sub-property', any way of getting powershell to return the value of sub-property?
I know I can do this with x-path with xml. But is there a syntactical way to get test 2 to work?