I have one custom config file.
<Students> <student> <Detail Name="abc" Class="1st Year"> <add key="Main" value="web"/> <add key="Optional" value="database"/> </Detail> </student> </Students>
I read this file through the implementation of the IConfigurationHandler interface. When I read the childNode attributes of the Detail element. It brings me back below the result in the Immediate Window IDE.
elem.Attributes.ToObjectArray() {object[2]} [0]: {Attribute, Name="key", Value="Main"} [1]: {Attribute, Name="value", Value="web"}
When I try to write on the console
Console.WriteLine("Value '{0}'",elem.Attributes.ToObjectArray());
he brings me back
Value : 'System.Configuration.ConfigXmlAttribute'
elem.Attributes.Item(1) method gives me a name and value, but here I need to pass the value of the attribute index, which I do not know at the moment.
I want to get the name and value of an attribute using a LINQ query and an individual console display for each childNode attribute as follows:
Value : Name="Key" and Value="Main" Name="value", Value="web"
How can i achieve this?
c # xml linq linq-to-xml
Saroop trivedi
source share