Read a dictionary element from xml



I'm trying to obtain the relevant xml attribute based on the value but I cannot get it to work.


What I am trying to achieve is based on the returned value I want to output the elements name.


Where am I going wrong?


Here's my code so far: XML:



<addresses>
<address name="house 1">No 1</ipaddress>
<address name="house 2">Flat 3</ipaddress>
<address name="house 3">Siccamore Drive</ipaddress>
</addresses>


C#:



string configPath = _AppPath + @"\HouseAddresses.xml";
XDocument addressXdoc = XDocument.Load(configPath);
XElement addressXmlList = addressXdoc.Element("traplistener");
foreach(XNode node in addressXmlLst.Element("addresses").Descendants())
{
PropertyList = ("string")node.Attribute("name");
}

No comments:

Post a Comment