I honestly don't know whether this will work in CF or not, but have you
tried:
xmlPeople.xmlRoot.xmlChildren[1].xmlAttributes.personid = 34442

that's the way they be doin it over in actionscript.

-----Original Message-----
From: Avi Flax [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 04, 2003 2:09 PM
To: CF-Talk
Subject: How to add attribute to element in xml object?

Quick question: once I've parsed an xml document, I know I can add elements
to any other element using the function xmlElemNew() - but I can't find a
way to do that programatically.

Example: someone passes to my code:

<people>
    <person name="Avi Flax" heightfeet="6" heightinches="5"
haircolor="brown"/>
</people>

and I want to return:

<people>
    <person name="Avi Flax" heightfeet="6" heightinches="5"
haircolor="brown" personid="34442"/>
</people>

so that the calling app/module can match up the id returned to the record
that was sent. I figure it'd be easier if I could just add my attribute in
and pass the xml packet back, without having to rebuild the whole xml doc.

I tried structInsert() but that didn't seem to work:

StructInsert(xmlPeople.xmlRoot.xmlChildren[1].xmlAttributes, "personid",
34442);

no dice.

Any ideas? Thanks!
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to