Read XML Element Attribute from Datatable RRS feed

  • Question

  • User843229376 posted

    I have method where datatable is loaded with XML from database (only one value i.e XML is returned)
    Now I want to read XML Attribute from datatable (without converting to XMLDocument or XDocument) and then assign to Object for a class

    Example :
    XML loaded in DATATABLE is


    Now there is class Employee

    public class Employee
      public string Name {get;set;}
      public int Age {get;set;}
      public string Place {get;set;}
      public string Employer {get;set;}

    So the attribute I get from Datatable.row[0] , I need to assign to corresponding object property

    Employee emp = new Employee();

    emp.Name = "Andy";
    emp.Age = 22;
    emp.Place = "Canada";
    emp.Employer = "IBM";

    NOTE: I need to do all this without going for either XMLDocument or Xdocument. Please help

    Thursday, February 21, 2013 2:06 AM