As you can see, I am creating the XML document and then referring to the collection of "girl" nodes using the pseudo node wrapper:

girls.girls.girl

I am then taking this pseudo node wrapper and iterating over it using the CFLoop tag. In ColdFusion 8, this would have thrown the following error:

Element XMLATTRIBUTES.NAME is undefined in GIRL.

However, in ColdFusion 9, this now works, and running the code above gives us the following output:

TriciaJoannaKim

Very cool! This is just another one of the small, incremental upgrades available in ColdFusion 9 that is going to make our lives easier. The pseudo XML node wrappers already helped; but, being able to iterate over them using CFLoop's array iteration feature is really going to maximize that efficiency.

The # signs are used to evaluate a ColdFusion variable. As such, the #girls.girls.girl# evaluates to the pseudo node XML wrapper and passes that to the "array" attribute.

You might see similar things in other languages like:

array="${girls.girls.girl}"

You could certainly use a user-defined variable to get a girl's name. You would do this in either as part of a dynamic XPath query or as part of the dot-notation turned array notation:

#girls[ FORM.inputname ].girl#

Here, the "inputname" would be a FORM variable posted by the user and used to navigate the XML document. Of course, in my example, the "inputname" would have to evaluate to "girls" in order for it to make sense.

I am the co-founder and lead engineer at InVision App, Inc — the world's leading prototyping,
collaboration & workflow platform. I also rock out in JavaScript and ColdFusion 24x7 and I dream about
promise resolving asynchronously.