I have the following XML and I have been trying Descendents().Descendents().Descendents to retrieve an element value but I can't get it to work.
I want to return the first value found in the first element of PersonID.
It is a string so I am doing this:
XDocument XDoc = XDocument.Parse(XmlString);
<Root>
<Code>200001</Code>
<MsgType>106</MsgType>
<PersonData>
<MSG>
<NewDataSet xmlns="PersonInstances">
<PersonInstances>
<PersonInstanceId>1</PersonInstanceId>
<PersonId>400</PersonId>
<Status>210005</Status>
<DateChanged>2009-10-20T11:53:00+01:00</DateChanged>
</PersonInstances>
<PersonInstances>
<PersonInstanceId>2</PersonInstanceId>
<PersonId>400</PersonId>
<Status>210005</Status>
<DateChanged>2009-10-20T12:13:00+01:00</DateChanged>
</PersonInstances>
<PersonInstances>
<PersonInstanceId>3</PersonInstanceId>
<PersonId>400</PersonId>
<Status>210005</Status>
<DateChanged>2009-10-20T15:28:00+01:00</DateChanged>
</PersonInstances>
<PersonInstances>
<PersonInstanceId>4</PersonInstanceId>
<PersonId>400</PersonId>
<Status>210005</Status>
<DateChanged>2009-10-20T15:32:00+01:00</DateChanged>
</PersonInstances>
<PersonInstances>
<PersonInstanceId>5</PersonInstanceId>
<PersonId>400</PersonId>
<Status>210005</Status>
<DateChanged>2009-10-21T10:49:00+01:00</DateChanged>
</PersonInstances>
<PersonInstances>
<PersonInstanceId>6</PersonInstanceId>
<PersonId>400</PersonId>
<Status>210005</Status>
<DateChanged>2009-10-21T17:15:00+01:00</DateChanged>
</PersonInstances>
<PersonInstances>
<PersonInstanceId>7</PersonInstanceId>
<PersonId>400</PersonId>
<Status>210005</Status>
<DateChanged>2009-10-22T10:06:00+01:00</DateChanged>
</PersonInstances>
<PersonInstances>
<PersonInstanceId>8</PersonInstanceId>
<PersonId>400</PersonId>
<Status>210005</Status>
<DateChanged>2009-10-22T16:01:00+01:00</DateChanged>
</PersonInstances>
</NewDataSet></MSG></PersonData></Root>