I have the following XML name Sample.xml which I am trying to query accountNo with XDocument:
<Request xmlns="http://CompanyName.AppName.version1">
<Person>
<AccountNo>83838</AccountNo>
<FirstName>Tom</FirstName>
<LastName>Jackson</LastName>
</Person>
<Person>
<AccountNo>789875</AccountNo>
<FirstName>Chris</FirstName>
<LastName>Smith</LastName>
</Person>
Using below code in C# i am able to fetch Account no of first person
XDocument xmlDoc = XDocument.Load("Sample.xml");
XNamespace nsSys = "http://CompanyName.AppName.version1";
XElement xEl2 = xmlDoc.Element(nsSys + "Request ");
XElement xEl3 = xEl2.Element(nsSys + "Person");
XElement xEl4 = xEl3.Element(nsSys + "AccountNo");
String sValue = xEl4.Value;
Ouput : 83838
How do you write code to extract account no of all person eg.
83838
789875