Last active
August 29, 2015 13:57
-
-
Save roundand/9910447 to your computer and use it in GitHub Desktop.
Demonstration of #XML #Canonicalisation in C# using #LinqPad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Query Kind="Statements"> | |
<Reference><RuntimeDirectory>\System.Security.dll</Reference> | |
<Namespace>System.Security.Cryptography.Xml</Namespace> | |
</Query> | |
// need to load System.Security via F4 | |
XmlDocument myDoc = new XmlDocument(); | |
myDoc.LoadXml("<root x='x' a='a'><trunk>etc</trunk></root>"); | |
myDoc.OuterXml.Dump("Attributes in original document order"); | |
XmlDsigC14NTransform t = new XmlDsigC14NTransform(); | |
t.LoadInput (myDoc); | |
var ms = (MemoryStream)t.GetOutput(); | |
var x = Encoding.ASCII.GetString(ms.ToArray()); | |
x.Dump("Attributes should be in alphabetical order"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment