the reason $xmlb is not working is because the string is actually parsed. I think. It's a bit of an illogical construction. Try var_dump()-ing it to see what value $xmlb is actually holding, it might be not quite what you're expecting. You could try using single quotes, so that the strings aren't parsed, but I'm guessing you'd need an eval() for it to start working again.
Your second option doesn't work because it's trying to parse $xmla[0] instead of test[0].