title: C# Hash complete xml
body: <p>We are trying to hash a xml file, i already have it working that it hashes the contents of the XML.
  For which i am using the following code:</p>
  
  <pre><code>        XmlDocument doc = new XmlDocument();
          doc.PreserveWhitespace = true;
          doc.Load(txtFile.Text);
  
          XmlNodeList list = doc.GetElementsByTagName("Document");
  
          XmlElement node = (XmlElement)list[0];
          //node.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
          string s = node.OuterXml;
  
          using (MemoryStream msIn = new MemoryStream(Encoding.UTF8.GetBytes(s)))
          {
              XmlDsigC14NTransform t = new XmlDsigC14NTransform(true);
              t.LoadInput(msIn);
              using (var hash = new SHA256Managed())
              {
                  byte[] digest = t.GetDigestedOutput(hash);
                  txtHash.Text = BitConverter.ToString(digest).Replace("-", String.Empty);
              }
          }
  </code></pre>
  
  <p>however, this only hashes the contents of the XML.
  What i need is to hash the complete XML instead of only the contents.</p>
  
  <p>If we only hash the contents, our hash doesnt compare with the control we get.</p>