In my WPF project, i need to have a xml file similiar to app.config file. So I added a xml file (Picture.xml) in my project and whose content is shown below :
<?xml version="1.0" encoding="utf-8" ?>
<Map>
<add filenumber="1" value="1.png"/>
<add filenumber="2" value="2.png"/>
<add filenumber="3" value="3.png"/>
<add filenumber="4" value="4.png"/>
</Map>
I have tried to get the value of a particular filenumber by doing as shown below.
XDocument doc = XDocument.Load("Picture.xml");
var keys = doc.Descendants("add").Select(x =>
x.Attribute("filenumber").Value);
But it is not getting the value for a particular filenumber. Is there any way to get the value of a particular key as like in the app.config. If we are using App.Config, then we can get the value of key by using the code
ConfigurationManager.AppSetting["key"]
something like this.
Is there any similar way to get the value like this from the Picture.xml file ?
If i supply 4 as the filenumber (key), then i should get "4.png" (value).