Consider the following code:
Class Demo
{
Person person = new Person("foo"); // assume Person class has a 'name' field.
//Now, how do I get the value of a field, using some expression.
String expression = "person.name";
}
Now, I want to evaluate the 'expression' to get the value of the 'name' attribute. Can anyone tell how it can be done?
-- Updated: the 'expression' string I'll be getting it from an XML file. So, will it be possible to use 'Reflection' in that scenario also? the 'expression' string may go into deeper levels also, like 'person.birthday.date'.