|
-
September 16th, 2004, 06:11 AM
#1
read xml files
Hi
I need to know how i can to read a xml file with the structure
I need a loop for to do this
but Anybody know the method?
My xml file
<configuration>
<appSettings>
<add key="key1" value="value1"/>
<add key="key2" value="value2"/>
<add key="key3" value="value3"/>
</appSettings>
</configuration>
i need to introduce "key1".... "keyn" and "value1"..."valuen" in a structura SortedList sl = new SortedList()
sl.Add(key,value)
Thanks very much
-
September 16th, 2004, 07:19 AM
#2
Re: read xml files
Why dobnt you just use something like XML Reader that could be found in System.XML nnameespace??
I will post a code for you as soon as i get home... it will bee in 3-4 hours...
Regards,
Alexei
-
September 16th, 2004, 10:15 AM
#3
Re: read xml files
If you are loading from a config file, then you don't need to use the XmlReader, it's already loaded into your Configuration.AppSettings collection, below is how you access it:
System.Configuration.ConfigurationSettings.AppSettings["key1"]
System.Configuration.ConfigurationSettings.AppSettings["key2"]
If you need to loop through it, just loop through the AppSettings collection.
Also, just in case you are not aware of this, but the xml config file must be named a certain way: YourAppNameHere.exe.config. If you need the code to iterate through the collection, I can post it. Hope this helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|