Not sure if there is a better way, but I fixed my issue by modifying your
"CreateAttribute" function - checking first to see if the attribute that i was
trying to create already existed, and only adding it if not. That way, if I set
the value immediately after adding the new child element, there is only one to
set...
// check to see if this already has this attribute set
if(pNodes.item(javacast('int',i)).GetAttribute('#arguments.name#') eq ""){
pNodes.item(javacast('int',i)).SetAttribute(arguments.name, arguments.value);
}
Cindi
> This is really great. The only thing that I can't figure out how to do
> is how to create an element and set an attribute at the same time. I
> need to create an element and give it an "id" attribute...
>
> Any suggestions?
>
> Otherwise, this rocks. Finds the exact thing that I'm looking for
> right away and adds an element to it...
>
> Cindi
>
>
>
>
> >I think this is the perfect situation for my betterXml component:
> >
> >http://betterxml.riaforge.org
> >
> >With it you could do this with only a few lines of code (XPath
> required), ie.
> >
> >oXml = CreateObject('component', 'betterXmlEditor').init(xmlSource);
> >// xml string, file or url for the source
> >
> >oXml.Update('//[EMAIL PROTECTED]"#theId#"]', theContentToAdd); //
> updates
> >all elements with id="#theId#" with theContentToAdd (can be either
> >structure or plain string);
> >oXml.Write(xmlFilePath);
> >
> >HTH
> >
> >Dominic
> >>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308932
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4