<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>replacing a node in in-memory XML</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial">Hi,</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">I am trying to figure out the best way to replace a node within an in-memory XML fragment.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">For example, lets say I have the following fragment in memory&#8230;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">&lt;communitygroup&gt;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">&lt;group&gt;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">&lt;name&gt;Test&lt;/name&gt;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">&lt;services&gt;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">&lt;service value=&quot;true&quot;&gt;2&lt;/service&gt;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">&lt;/services&gt;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">&lt;/group&gt;</FONT>

<BR><FONT SIZE=2 FACE="Arial">&lt;/communitygroup&gt;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">&#8230;and want to replace the services node with the following&#8230;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">&lt;services&gt;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">&lt;service value=&quot;false&quot;&gt;1&lt;/service&gt;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">&lt;service value=&quot;true&quot;&gt;2&lt;/service&gt;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">&lt;service value=&quot;false&quot;&gt;3&lt;/service&gt;</FONT>

<BR><FONT SIZE=2 FACE="Arial">&lt;/services&gt;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Is there a way of doing this in XQuery?</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Obviously I could use an XSL transformation, which would give me the result I want, but maybe there is a more efficient way using XQuery?</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Thanks</FONT>

<BR><FONT SIZE=2 FACE="Arial">Rob Walpole</FONT>

<BR><FONT SIZE=2 FACE="Arial">Devon Portal Developer</FONT>

<BR><FONT SIZE=2 FACE="Arial">Email robert.walpole@devon.gov.uk</FONT>

<BR><FONT SIZE=2 FACE="Arial">Web </FONT><A HREF="http://www.devonline.gov.uk"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">http://www.devonline.gov.uk</FONT></U></A>
</P>

</BODY>
</HTML>