Can someone please tell me how to run foreach
cycle that goes through every element Person
I have this code for loading but doc1
is not filled with data
XDocument doc = XDocument.Load(path);
foreach (var doc1 in doc.Descendants("Person"))
The XML looks like this
<Report xmlns="http://askmk/ask/Report">
<ReportTypeId>5</ReportTypeId>
<BankId>111</BankId>
<ReferenceNo>1</ReferenceNo>
<ReferenceNoReporter />
<DateCreated>2017-01-31T01:50:44.0000000+01:00</DateCreated>
<DataFromDate>2017-01-27T12:00:00.0000000+01:00</DataFromDate>
<DataToDate>2017-01-27T12:00:00.0000000+01:00</DataToDate>
<PersonList>
<Person xmlns="http://askmk/ask/ReportTypes">
<PersonObjectId>111</PersonObjectId>
<CellPhoneNo>111 </CellPhoneNo>
<DateOfBirth>1985-03-18</DateOfBirth>
<Email />
<EMBG>111111</EMBG>
<IsResident>1</IsResident>
<FirstName>xxx</FirstName>
<GenderTypeId>3</GenderTypeId>
<LastName>xxx</LastName>
<PhoneNo />
<PlaceOfBirth />
<IdDocumentList>
<IdDocument>
<IdDocumentTypeId>1</IdDocumentTypeId>
<PlaceOfIssue>. </PlaceOfIssue>
<IdNo>1111</IdNo>
</IdDocument>
</IdDocumentList>
</Person>
<Person xmlns="http://askmk/ask/ReportTypes">
<PersonObjectId>1111</PersonObjectId>
<CellPhoneNo>11111 </CellPhoneNo>
<DateOfBirth>1969-03-28</DateOfBirth>
<Email />
<EMBG>1111</EMBG>
<IsResident>1</IsResident>
<FirstName>xxx</FirstName>
<GenderTypeId>3</GenderTypeId>
<LastName>xxx</LastName>
<PhoneNo />
<PlaceOfBirth />
<IdDocumentList>
<IdDocument>
<IdDocumentTypeId>2</IdDocumentTypeId>
<PlaceOfIssue>xxxx </PlaceOfIssue>
<IdNo>1111</IdNo>
</IdDocument>
</IdDocumentList>
</Person>
</PersonList>
</Report>
I know that this is simple but i am new to this c# and thats why i am asking.