PROBLEMS ACCESSING CERTAIN NODE READING XML WITH C#

Jayden Bell

Total Post:110

Points:774
Posted by  Jayden Bell
C# 
C#
 1185  View(s)
Ratings:
Rate this:

My XML looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

  <something.logger>

    <add key="LoggerId" value="8a2ff9ef-d144-4dcb-86d8-6ccaf44def20">

    </add>

    <add key="FederationId" value="00000000-0000-0000-0000-000000000000" />

  </something.logger>

 </configuration>

My code:

XmlDocument xml = new XmlDocument();

xml.Load(Some-Valid-Path);

XmlNodeList xnList = xml.SelectNodes("/configuration/something.logger");

I am trying to get the Guid (or value..) of value.

In the end i want to get the string "8a2ff9ef-d144-4dcb-86d8-6ccaf44def20"

Thanks !

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Problems accessing certain node reading xml with C#

    Hi Jayden, 

    Try this:

    XmlNodeList xnList = xml.SelectNodes("/configuration/something.logger/add/@value");

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!