i have an XML document acting as a repository for user preferences. Users may get/set/remove preferences by simply querying for keys in dotted notation as follows:
What i would like to do is translate the input String "application.background.color" into an equivalent e4x expression to be executed on my XML document. I searched the net and read some books about Flex, but i'm really not able to figure out how to do it at runtime. Anyway it sounds to me a little bit weird not providing users with an E4X parser.
Does anyone else has ever faced the same problem? Is there a clean solution to translate Strings into E4X filters?
Thank you very much in advance.
For simple mappings like application.background.color, array syntax may work. You could try tokenizing the string and traversing with a loop using the array syntax.
Thanks rootsounds..yes, this could be a solution. The most simple one and the very first that came into my mind. I was wondering whether there's a more powerful way of doing it.
Moreover the one i've written was only an example and i have to manage complex most of all complex keys.
I found some (very) unofficial libraries for E4X parsing, but i can't rely on someone else's not maintained and not tested nightly experiments.