Re: Embed an XML document into another?

2006-10-12 Thread Jon Gunnip
Craig,

You can't just merge two XML documents together in CF the way you are
doing it.  Spike has an excellent explanation here:
http://www.spike.org.uk/blog/index.cfm?do=blog.cat&catid=8245E3A4-D565-E33F-39BC6E864D6B5DAA.

One simple approach you can take is to turn both the XML documents
into strings using ToString(), insert one of the strings into the
other using a regex, and then use XMLParse() on the combined XML
string to get a new XML object.

HTH,
Jon

On 10/11/06, Craig Drabik <[EMAIL PROTECTED]> wrote:
> I have an application that kicks around data about an event from function to 
> function in an  XML document.  If I have an error I'm trapping with 
> try/catch, I want to use wddx to serialize the cfcatch struct, parse it to 
> XML, and embed it in the error element in my event XML.
>
> if I try:
>
>
> 
> 
>  xError = xmlparse(replace(errorXml, 'wddxPacket', 'wddx-packet', 
> 'ALL')); //Stops CF fromseeing a wddx packet "type"
>  structInsert(xEvent.event.error, "wddx-packet", xError);
> 
>
> I get:
>
>  The XML node [#document] has type [DOCUMENT] which cannot be added to the 
> content of an element.
>
> In order to get a node, not a document, if I replace:
>
>  structInsert(xEvent.event.error, "wddx-packet", xError);
>
> with:
>
>  structInsert(xEvent.event.error, "wddx-packet", x["wddx-packet"]);
>
> I get:
>
> WRONG_DOCUMENT_ERR: A node is used in a different document than the one that 
> created it.
>
>
>
> Anybody have any ideas?
>
> 

~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

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


Embed an XML document into another?

2006-10-11 Thread Craig Drabik
I have an application that kicks around data about an event from function to 
function in an  XML document.  If I have an error I'm trapping with try/catch, 
I want to use wddx to serialize the cfcatch struct, parse it to XML, and embed 
it in the error element in my event XML.

if I try:




 xError = xmlparse(replace(errorXml, 'wddxPacket', 'wddx-packet', 'ALL')); 
//Stops CF fromseeing a wddx packet "type"
 structInsert(xEvent.event.error, "wddx-packet", xError);


I get:

 The XML node [#document] has type [DOCUMENT] which cannot be added to the 
content of an element.

In order to get a node, not a document, if I replace:

 structInsert(xEvent.event.error, "wddx-packet", xError);

with:

 structInsert(xEvent.event.error, "wddx-packet", x["wddx-packet"]);

I get:

WRONG_DOCUMENT_ERR: A node is used in a different document than the one that 
created it.



Anybody have any ideas?

~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

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