I have an xml file that looks like this:
<Employee>
<EmployeeName>Burt Reynolds</EmployeeName>
<EmployeeTitle>Bad Ass</EmployeeTitle>
<EmployeeStory>
<EmployeeStoryHeaderParagraph>
<EmployeeHeader>Employee Header 1</EmployeeHeader>
<EmployeeParagraphs>
<EmployeeParagraph>Employee Paragraph 1.1</EmployeeParagraph>
</EmployeeParagraphs>
<EmployeeParagraphs>
<EmployeeParagraph>Employee Paragraph 1.2</EmployeeParagraph>
</EmployeeParagraphs>
</EmployeeStoryHeaderParagraph>
<EmployeeStoryHeaderParagraph>
<EmployeeHeader>Employee Header 2</EmployeeHeader>
<EmployeeParagraphs>
<EmployeeParagraph>Employee Paragraph 2.1</EmployeeParagraph>
</EmployeeParagraphs>
<EmployeeParagraphs>
<EmployeeParagraph>Employee Paragraph 2.2</EmployeeParagraph>
</EmployeeParagraphs>
</EmployeeStoryHeaderParagraph>
</EmployeeStory>
<EmployeeImage>
<include type="Image" resolve="false" sourcedFrom="local" externalPath="/PublishingImages/2nav_bg.png" height="29" width="2" query="">/PublishingImages/2nav_bg.png</include>
</EmployeeImage>
<EmployeeSigImage>
<include type="Image" resolve="false" sourcedFrom="local" externalPath="/PublishingImages/down_carat.gif" height="7" width="12" query="">/PublishingImages/down_carat.gif</include>
</EmployeeSigImage>
<EmployeeVideo>http://sandbox/RichMedia/Robotica_720.wmv</EmployeeVideo>
</Employee>
The Employee tag is sent from 1 to n. The EmployeeStoryHeaderParagraph tag is 1 - n. The EmployeeParagraphs tag is sent from 1 to n.
I am trying to create an object and add it to the list using this data, but I am stuck in capturing headings and paragraphs. Currently, the code is as follows.
XDocument employeeXML = XDocument.Parse(e.Result);
employeeList = (from employee in employeeXML.Descendants(ns + "Employee")
select new Employee(employee.Element(ns + "EmployeeName").Value,
employee.Element(ns + "EmployeeTitle").Value,
employee.Element(ns + "EmployeeImage").Element(ns + "include").Attribute("externalPath").Value,
employee.Element(ns + "EmployeeSigImage").Element(ns + "include").Attribute("externalPath").Value,
employee.Element(ns + "EmployeeVideo").Value,
headers,
content
)).ToList();
An employee is a class that I created that takes this as a constructor;
public Employee(string _employeeName, string _employeeTitle, string _employeeImage, string _employeeSigImage, string _employeeMovieUri, List<string> _employeeHeader, List<string[]> _employeeContent)
Linq , , , , . , EmployeeParagraphs, . , [1] [1] . , Linq, , , , ?
, , ?