0

I have the following xml

<?xml version="1.0" encoding="UTF-8"?>
<tests>
  <testdef name="Gaps (Simple)">
    <property GapInterval="null" />
    <property ReturnAllOpt="null" />
  </testdef>
  <testdef name="Gaps (Holiday Aware)">
    <property GapInterval="null" />
    <property HolidayOrigin="null" />
    <property ReturnAllOpt="null" />
  </testdef>

I need to get the attributes of property for each of the testdef name.

List<string> values = new List<string>();
  XmlNodeList valueslist =  propdoc.GetElementsByTagName("testdef");

    for (int i = 0; i < valueslist.Count; i++)
    {
        values.Add(valueslist[i].InnerXml);
        Console.WriteLine(valueslist[i].InnerXml);
    }

I have written the following code where I get the whole attribute of the testdef. Is there any way I can achieve my goal.

Bhushan
  • 1
  • 2
  • 3
    You may want to check this out ... http://stackoverflow.com/questions/670563/linq-to-read-xml – KornMuffin Jun 13 '16 at 15:14
  • 1
    @Bhusan I think you have to hard code the `attribute` names if you want to get their values or you have to make changes to your xml – Chaitanya Jun 13 '16 at 17:12
  • @Chaitanya I tried but ia m not sure how i would be going ahead with the solution. I am trying to get the following solution: – Bhushan Jun 14 '16 at 16:11

0 Answers0