0

Ok, I have an xml document which is returned via a c# function and output via XSLT. In the XML document there is an encrypted string which I need to decrypt before output.

Basically, i need to run "encryptedstring" through a decrypting function in order get the real value.

XML Structure:

<root>
<order encryptedstring="676696969hjhig">
</root>

Outputting function:

XmlDocument xmlOrders = Data_Functions.Get_All_Orders();
xmlOutput.DocumentContent = xmlOrders.OuterXml;

I am assuming i need to loop through the XML document, get the value for each "encryptedstring", run that value through the decrypt function and re-inject it back into the xml document but am unsure of best way to go about that.

The decryption has to be done in the codebehind in c# by passing a string through decryptString();

CloudSurferUK
  • 95
  • 1
  • 13
  • try looking at this question: http://stackoverflow.com/questions/2558787/how-to-modify-existing-xml-file-with-xmldocument-and-xmlnode-in-c-sharp – momar Sep 09 '16 at 14:33

1 Answers1

0

With a bit of guidance from the question suggestion by @momar this was solved in the following way...

XmlNodeList aNodes = xmlOrders.SelectNodes("//root/order");

        foreach (XmlNode aNode in aNodes)
        {
            XmlAttribute ccAttribute = aNode.Attributes["encryptedstring"];

            string attValue= ccAttribute.Value;
            string encKey = ConfigurationManager.AppSettings["EncryptionKey"];
            string decrypt = Crypto.DecryptStringAES(attValue, encKey);

            ccAttribute.Value = deencrypt;

        }
xmlOutput.DocumentContent = xmlOrders.OuterXml;
CloudSurferUK
  • 95
  • 1
  • 13