Varshini S
asked on
How to read a string using InnerXml ?
I am using following code to read a string from XML file. I have to read
a following string from the XML file. How to read this string ? "mcQKhSSzcMP9199vA8Bod1/y6 VJrZNL3m4A QiDHwonHyu SUctBQY/cg Oz5rakHa2d 5mVKSSxdE2 RjDDB0DxKU soWbddaeej 6ufY6fUj6A CmwJQyiB+I 3OA=="
c# code:
XML File:
a following string from the XML file. How to read this string ? "mcQKhSSzcMP9199vA8Bod1/y6
c# code:
XmlDataDocument doc = new XmlDataDocument();
doc.Load(@"C:\Temp\Connection.exe.config");
XmlElement root = doc.DocumentElement;
XmlNodeList elemList = root.GetElementsByTagName("connectionStrings");
XML File:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<clear/>
<add name="Encrypted"
providerName="System.Data.SqlClient"
connectionString="mcQKhSSzcMP9199vA8Bod1/y6VJrZNL3m4AQiDHwonHyuSUctBQY/cgOz5rakHa2d5mVKSSxdE2RjDDB0DxKUsoWbddaeej6ufY6fUj6ACmwJQyiB+I3OA=="
/>
</connectionStrings>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<clear/>
<add name="Encrypted"
providerName="System.Data.SqlClient"
connectionString="mcQKhSSzcMP9199vA8Bod1/y6VJrZNL3m4AQiDHwonHyuSUctBQY/cgOz5rakHa2d5mVKSSxdE2RjDDB0DxKUsoWbddaeej6ufY6fUj6ACmwJQyiB+I3OA=="
/>
</connectionStrings>
</configuration>
Don't access your config files manually. Use the ConfigManager class instead.
ASKER
ste5an: You are absolutely correct. But for this scenario I need to read manually.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are alreading reading your string. But I guess you want to decrypt this string.
Normally you would use an Protected Configuration Provider.
The problem is quite simple: I don't recognize this encryption schema...
So hard to tell. How was this config file generated?
Normally you would use an Protected Configuration Provider.
The problem is quite simple: I don't recognize this encryption schema...
So hard to tell. How was this config file generated?
@ste5an - Offhand it looks like an encoded public or private key generated using the RSACryptoServiceProvider.
-saige-
-saige-
ASKER
ste5an - Application configuration file sitting in outside my application and more than 5 application sharing the same config file. So I have used TripleDES encryption and generated the keys. During the run time I will decrypt the connection string.
@Varshini - Have you looked at the code I provided to see if that leads you down the right path? If needed I could provide more information.
-saige-
-saige-
ASKER
Saige- Thank You. This works for me
Don't forget to accept the solution.
-saige-
-saige-