7

Given the following domain object:

public class Domain {
   private String field1 = "one";
   private String field2 = "two";
}

how should the mapping.xml file be structured so the XML output looks like this:

<DomainObjects>
  <row field1="one">
      <field2>two</field2>
  </row>
<DomainObjects>

where "DomainObjects" is a static label.

Thanks very much

user1052610
  • 4,440
  • 13
  • 50
  • 101

1 Answers1

0
[XmlType("domain"), XmlRoot("domain")]
public class Domain {
    [XmlAttribute("field1")]
    public string field1 {get;set;}
    [XmlAttribute("field2")]
    public decimal field2 {get;set;}

Also you can get values

var result = from e in XDocument.Load("yourfile.xml").Descedants("Domain")
                  select new Domain{field1=e.Element("field1").Value,field2=e.Element("field2").Value};
Jerin
  • 3,657
  • 3
  • 20
  • 45