Skip navigation
Currently Being Moderated

Create i:nil XML Attribute

Oct 11, 2013 7:48 AM

Tags: #xml #coldfusion8 #cf8

I need to create an XML Document with an element that requires the attribute i:nil=true. I've tried <cfset StructInsert(, "i:nil", "true")>, but it returns the error "The right hand side of the assignment is not of type XML Node".


What I want is to create an element like this: <name i:nil="true"/>


Any help would be greatly appreciated.

  • Currently Being Moderated
    Oct 13, 2013 2:21 PM   in reply to rhpt

    What does this produce?


    <cfdump var="#isStruct( )#" />


    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" />

    Mark as:
  • Currently Being Moderated
    Oct 14, 2013 8:58 AM   in reply to rhpt

    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.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points