Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
3.33/5 (2 votes)
See more:
Actually I have read app.config file in 2 different way
1. In this way,
XML
<SecutiryNode>
<add name="myname1" accessnode ="$\single\double" Secutiry="Admin;new guest;old guest"/>
<add name="myname2" accessnode ="$\alpha\beta" Secutiry="Admin;new guest;old guest"/>
<SecutiryNode>


2.
XML
<SecutiryNode>
<add name="myname1" accessnode ="$\single\double">
<Secutiry>Admin<Secutiry/>
<Secutiry>new guest<Secutiry/>
<Secutiry>old guest<Secutiry/>

<add/>
<add name="myname2" accessnode ="$\alpha\beta" Secutiry="Admin;new guest;old guest"/>
<Secutiry>Admin<Secutiry/>
<Secutiry>new guest<Secutiry/>
<Secutiry>old guest<Secutiry/>
<add/>
<SecutiryNode>



Please help me for find solution in both type since i have implement in both the ways.
Posted
Updated 24-Jan-10 21:27pm
v2

The AppSettings node requires a specific format.
Instead you can use the config section.

Define the config section at the beginning of config file as :
XML
<configSections>
    <section name="SecurityNode" type="<namespace of the dll that is going to read this", <dll name>"/>
  </configSections>


Then use the ConfigurationManager.GetSection("SecutiryNode") statement to read the whole node and process it as normat xml.

Hope this helps
 
Share this answer
 
Comments
Dalek Dave 19-Apr-11 3:24am    
Good Call.
Dipti Mehta 20-Apr-11 1:25am    
Hi Sunrise1978 , could you reach to a conclusion?
@Dalek , thanks :)
You can use following code to get your entire "SecurityNode" section:

ConfigurationManager.GetSection("SecutiryNode")
 
Share this answer
 
I suggest that if your clients speak English, you should use a dictionary so that your XML is spelled correctly.

The way to read XML is to use the XmlDocument class, and XPath to search for the nodes that have the values you need. This will work regardless of if you are searching child nodes, or attributes.
 
Share this answer
 
The app.config file requires a very specific format, and DotNet provides a built-in reader for that file. If you have another file you want to read, you will probably need to write code to do so (or you may find a generic XML-reader class somewhere on the net). My advice is to use Linq-to-Xml because it's a lot easier tan using the DotNet 2.0 XmlDocument/XPath stuff.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900