I have some XML:
<Request>
<EmailAddress>string</EmailAddress>
<Item>
<name>FirstName</name>
<value>John</value>
</Item>
<Item>
<name>LastName</name>
<value>Doe</value>
</Item>
</Request>
My object:
public class TheObject{
public string EmailAddress { get; set; }
public string SkuNumber { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
I want to use LINQtoXML to pull out the FirstName and LastName values from the above XML to build the object. How would I do this?
Update: Here is my code I started:
var object =
xml.Descendants("Request").Select(
x =>
new TheObject()
{
EmailAddress = x.Element("EmailAddress").Value.ToString(),
SkuNumber = x.Element("SKU").Value.ToString(),
FirstName = ...,
LastName = ....
})