What does this produce?
<cfdump var="#isStruct( mydoc.employee.name.xmlAttributes )#" />
If it's Yes/True, I think the problem here has to do with you attempting to set a key with a value that is not permitted. Variables cannot have special characters like ':' in them. To quickly test this, change 'i:nil' to 'i_nil' since underscores are permitted.
The xmlAttributes() method returns back a structure of key/value pairs.
Is it valid for an XML node to look like:
<user lastname="smith" firstname="john" i:nil="true" /> ?
Not sure that's allowed.
If you're attempting to use namespaces, those are placed onto the root element <user> not its attributes. Like:
<i:user lastname="smith" firstname="john" />
1 person found this helpful
Figured this out thank to Stackoverflow. Simply use a direct assignment.
<cfset mydoc.employee.name.xmlAttributes["i:nil"] = true>
Happy you got it rolling, but I gotta say I'm very surprised here.
To my knowledge the xmlAttributes() function returns a structure, which is just a series of name/value pairs. I guess I'm so used to keeping special characters outside of my variable names that I never really tried to set one with a colon in it. Come to think of it, I think CF is more concerned about the FIRST character of the variable name than subsequent ones. Like, the variable couldn't be called ':nil', because it began with the colon, but the colon could exist as a subsequent character in the variable name.
Good to know.