I think I typed this out right... might be some typos.  Basically use 
XmlElemNew to create the new node then assign it's XmlAttributes and XmlText to 
what you want.


<cfset xml = XMLParse(#XMLgoesHere#)>

<cfset 
xml.BackgroundCheck.BackgroundSearchPackage.Screenings.ClientReferences.XmlChildren[2]
 =  XmlElemNew(xml, "IdValue")>

<cfset 
xml.BackgroundCheck.BackgroundSearchPackage.Screenings.ClientReferences.IdValue[2].XmlAttributes.name
 = "ClientReferenceField2_Value">

<cfset 
xml.BackgroundCheck.BackgroundSearchPackage.Screenings.ClientReferences.IdValue[2].XmlText
 = "crf2">


-----Original Message-----
From: Lee [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 25, 2007 10:24 AM
To: CF-Talk
Subject: XML Insert Problem

We are having trouble inserting a line into XML when using 
straight string manipulation it blows up on XML Search. We 
are guessing that there is a better
way to insert the line. Details below.

The existing XML structure shows (partial XML is noted in 
the examples below and does not represent the entire xml 
document):

<ClientReferences>

             <IdValue 
name="ClientReferenceField2_Value">crf2</IdValue>

</ClientReferences>


We wish to add another <IdValue> node before the 
ClientReferenceField2_Value attribute as follows:

  
             <IdValue 
name="ClientReferenceField1_Value">crf1</IdValue>


The resulting XML structure would show:


<ClientReferences>

             <IdValue 
name="ClientReferenceField1_Value">crf1</IdValue>

             <IdValue 
name="ClientReferenceField2_Value">crf2</IdValue>

</ClientReferences>

The full Xpath to <ClientReferences> is as follows:

/BackgroundCheck/BackgroundSearchPackage/Screenings/ClientReferences

Notes:

-          Assume the existing XML document is in a 
ColdFusion structure through the use of XmlParse()

-          The resulting XML should be maintained as a 
ColdFusion structure that will allow Xpath searches using 
XMLSearch()

  

  



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Download the latest ColdFusion 8 utilities including Report Builder,
plug-ins for Eclipse and Dreamweaver updates.
http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:284561
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to