I am able to combine the chunks together and remove the initial root element tags as 
suggested below.  Thanks for the help.  I'm now facing a problem of needing to be able 
to merge 2 form elements together.  Notice in the example below, each xml chunk has a 
form element with an element name of txtContentHeader.  Any suggestions on merging 
these together?

Thanks - Tom

-----Original Message-----
From: tom dyson [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 21, 2002 5:13 AM
To: [EMAIL PROTECTED]
Subject: Re: [cf-xml] xml merge


Hi Tom (Schreck)

The easiest way to do this will be through ColdFusion text manipulation.
Something like this (in <cfscript> tags):

// combine the XML chunks
fullxml = xmlchunk_1 & xmlchunk_2;

// remove all the root elements
fullxml = replace(fullxml,'<XMLDescriptor>','','all');
fullxml = replace(fullxml,'</XMLDescriptor>','','all');

// replace the root elements at the beginning and end of the combined chunk
fullxml = '<XMLDescriptor>' & fullxml & '</XMLDescriptor>';

Hope this helps

Tom (Dyson)

-----------------+
tom dyson
t: +44 (0)1608 811870
m: +44 (0)7958 752657
http://torchbox.com

> Thanks for the tip.  I'm learning xml and am excited about its possibilities.
> Each chunk I need to merge has the same root element.  How should I manage
> that?  Ideally, I would like to have 1 <XMLDescriptor> root element and just
> merge the <FormElement> elements.  Here's an example of the chunks I'm trying
> to merge:
> 
> XML Chunk #1:
> <XMLDescriptor>
>  <FormElement TYPE="Memo">
>     <elementName>txtContentHeader</elementName>
>     <elementLabel>Title</elementLabel>
>     <ynIsRequired>1</ynIsRequired>
>     <xslMember>Abstract,Header</xslMember>
>     <editLevel>1</editLevel>
>     <defaultValue/>
>     <elementSize>35</elementSize>
>     <elementMaxLength>50</elementMaxLength>
>     <elementClass>txtBlack14</elementClass>
>     <elementLabelClass>txtGray14</elementLabelClass>
>     <elementPosition>1</elementPosition>
>  </FormElement>
>  <FormElement TYPE="Hidden">
>     <elementName>numSubmittedByID</elementName>
>     <elementLabel>Submitted By</elementLabel>
>     <ynIsRequired>1</ynIsRequired>
>     <xslMember/>
>     <editLevel>0</editLevel>
>     <defaultValue>client.numPersonnelID</defaultValue>
>     <elementSize/>
>     <elementMaxLength/>
>     <elementClass/>
>     <elementLabelClass/>
>     <elementPosition>2</elementPosition>
>  </FormElement>
> </XMLDescriptor>
> 
> XML Chunk #2:
> <XMLDescriptor>
>  <FormElement TYPE="Memo">
>     <elementName>txtContentHeader</elementName>
>     <elementLabel>Test Merge Label</elementLabel>
>  </FormElement>
>  <FormElement TYPE="Text">
>     <elementName>txtTest</elementName>
>     <elementLabel>Test</elementLabel>
>     <ynIsRequired>0</ynIsRequired>
>     <ynIsInherited>0</ynIsInherited>
>     <xslMember>Abstract,Header</xslMember>
>     <editLevel>1</editLevel>
>     <defaultValue/>
>     <elementSize>35</elementSize>
>     <elementMaxLength>50</elementMaxLength>
>     <elementClass>txtBlack14</elementClass>
>     <elementLabelClass>txtGray14</elementLabelClass>
>     <elementPosition>1</elementPosition>
>  </FormElement>
> </XMLDescriptor>
> 
> 
> I appreciate your help.
> 
> Tom
> 
> -----Original Message-----
> From: Matthew Drayer [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 20, 2002 8:53 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [cf-xml] xml merge
> 
> 
> Hi Tom,
> 
> Try this:
> 
> <cfscript>
> 
> XMLPacket = "<?xml version=""1.0""?>";
> XMLPacket = XMLPacket & cfvariable_1;
> XMLPacket = XMLPacket & cfvariable_2;
> XMLPacket = XMLPacket & cfvariable_3;
> etc.
> </cfscript>
> 
> You can also lump them all into one line, by doing this:
> 
> XMLPacket = "<?xml version=""1.0""?>" & cfvariable1 & cfvariable2...
> ;
> 
> Doing it the first way you can use if(IsDefined()) to check for the presence
> of the variables, however, there is a little more overhead due to CF writing
> a new string to memory on each line (not much, though).
> 
> Hope this helps,
> 
> Matt
> 
> -----Original Message-----
> From: Schreck, Tom [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 20, 2002 9:47 AM
> To: [EMAIL PROTECTED]
> Subject: [cf-xml] xml merge
> 
> 
> I'm needing to take multiple cf variables containing xml chunks and merge
> them into 1 xml document.  I'd appreciate any insight into how this can be
> accomplished.
> 
> Thanks - Tom
> 



-----------------------+
cf-xml mailing list
list: [EMAIL PROTECTED]
admin: [EMAIL PROTECTED]
home: http://torchbox.com/xml

-----------------------+
cf-xml mailing list
list: [EMAIL PROTECTED]
admin: [EMAIL PROTECTED]
home: http://torchbox.com/xml

Reply via email to