I’m trying to read a XML file, but I want to know just the name of the node and her value.
Example
<User>
<Contact>
<Name>Lucas</Name>
<ID>123</ID>
</Contact>
</User>
I’m trying use this code below but without success. How can I return just the node name and her value ?
foreach (var name in doc2.Root.DescendantNodes().OfType<XNode>().Select(x => x).Distinct())
{
string nome = name.ToString();
}
I want that my string receives the name of my Node, is this case will be Name and her value, that will be Lucas
1 Answer