Question: I'm trying to figure out to to combine a serialized object with an existing xml doc and return it as a webservice.

Thanks ahead for you help.

Sample code:

```
[WebMethod]
    public string GetApple()
    {

    Apples apples = Report.GetReport();
    //  this returns:
        //  <Apples xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
        //  <Name>Smtih</Name>
        //  <Size>11</Size>
        //  <Weight>111</Weight>
        //  <Color>Red</Color>
        //  </Apples>

    string TemplatePath = Server.MapPath("~/Template.xml");
        // this is:
        // <?xml version="1.0" encoding="utf-8" ?>
        // <applereport>
        //  <moretags>
        //    <july>
        //      <report>
        //        <DATA-GOES-HERE></DATA-GOES-HERE>
        //      </report>
        //    </july>
        //  </moretags>
        // </applereport>

        // Read TemplatePath into a memory stream
        // find the node: <DATA-GOES-HERE></DATA-GOES-HERE>
        // 
        // put serialixed output of Report.GetReport() where <DATA-GOES-HERE></DATA-GOES-HERE> is

        return FullReport;
}

```

Answer: 
In C and C++ strings are *usually* stored in memory as 8-bit char values where the value stored is the [ASCII](http://en.wikipedia.org/wiki/ASCII) value of the character.

Your code is therefore XORing the ASCII values. For example, the second character in your output is calculated as follows:

```

  'B' ^ ' '
= 66 ^ 32
= 01000010 ^ 00100000
= 01100010
= 98
= 'b'

```

You could get a different result if you ran this code on a system which uses [EBCDIC](http://en.wikipedia.org/wiki/Extended_Binary_Coded_Decimal_Interchange_Code) instead of ASCII.
This is a simple demonstration of one time pad encryption, which as you can see is quite simple and also happens to be the only provably unbreakable form of encryption. Due to it being symmetric and having a key as large as the message, it's often not practical, but it still has a number of interesting applications.. :-)

One fun thing to notice if you're not already familiar with it is the symmetry between the key and the ciphertext. After generating them, there's no distinction of which one is which, i.e. which one was created first and which was based on the plaintext xor'd with the other. Aside from basic encryption this also leads to applications in plausible deniability.