title: How do you compare decendants that are on multiple levels
body: <p>I am currently working with XML files in which i must retrieve nodes under a particular element. These nodes mostly contain <code>DateTime</code> objects and when they are retrieved they get updated. The problem is one of the attributes is two levels lower than the rest (causing the need for a second <code>.Descendants</code>). How can I compare the attribute that is two levels lower (<code>_StartDate</code>) with one of the attributes that isn't. I'm specifically looking to compare <code>_StartDate</code> with <code>_AccountReportedDate</code>.</p>
  
  <pre><code>var creditLiabilities = xDoc.Descendants("CREDIT_LIABILITY").Descendants("_PAYMENT_PATTERN")
                  .Select(x =&gt; new
                      {
                          Element = x,
                          AccountOpenedDate = x.Attribute("_AccountOpenedDate") == null ? string.Empty : x.Attribute("_AccountOpenedDate").Value + "-01",
                          AccountClosedDate = x.Attribute("_AccountClosedDate") == null ? string.Empty : x.Attribute("_AccountClosedDate").Value + "-01",
                          AccountPaidDate = x.Attribute("_AccountPaidDate") == null ? string.Empty : x.Attribute("_AccountPaidDate").Value + "-01",
                          AccountReportedDate = x.Attribute("_AccountReportedDate") == null ? string.Empty : x.Attribute("_AccountReportedDate").Value + "-01",
                          LastActivityDate = x.Attribute("_LastActivityDate") == null ? string.Empty : x.Attribute("_LastActivityDate").Value + "-01",
                          AccountStatusDate = x.Attribute("_AccountStatusDate") == null ? string.Empty : x.Attribute("_AccountStatusDate").Value + "-01",
                          Monthcount = x.Attribute("_MonthsReviewedCount") == null ? string.Empty : x.Attribute("_MonthsReviewedCount").Value,
                          StartDate = x.Attribute("_StartDate") == null ? string.Empty :x.Attribute("_StartDate").Value,
                      }
                 ); 
  </code></pre>
  
  <p>Below is the XML code:</p>
  
  <pre><code>&lt;CREDIT_LIABILITY CreditLiabilityID="CreditLiabilityID_52885" x_MasterTradelineId="52885" x_CDOTradelineId="153216" BorrowerID="Borrower" CreditFileID="CreditFileId_14462 CreditFileId_14460 CreditFileId_14461" x_TradelineGroupId="152665" x_Primary="Y" x_BureauName="Experian" x_SubscriberCode="1631440" _AccountIdentifier="7634134580" _AccountOpenedDate="2014-04" _AccountOwnershipType="Individual" _AccountReportedDate="2014-11" _AccountStatusDate="2015-01" _AccountStatusType="Open" x_FannieAccountStatusType="Open" x_StatusLong="Current account/was 30 days past due date" _AccountType="Installment" _ConsumerDisputeIndicator="N" _DerogatoryDataIndicator="N" _HighBalanceAmount="21811.00" _LastActivityDate="2014-09" _ManualUpdateIndicator="N" x_ActualPaymentAmount="363.00" _MonthsReviewedCount="8" _TermsMonthsCount="60" _UnpaidBalanceAmount="19993.00" x_UnpaidBalanceNumber="19993.0000" CreditLoanType="CreditCard" x_FNMACreditLoanCode="CC" x_RealEstateRelated="0" x_PrimaryRealEstate="0" x_ECOA2="B" x_CREDITOR_Name="FORD CRED" x_PrimaryGroupBy="Installment" _MonthlyPaymentAmount="363.00" _TermsSourceType="Provided" x_EstPayment="N" x_EstPaymentPct="0.020" _MonthsRemainingCount="53"&gt;
        &lt;_CREDITOR _Name="FORD CRED" /&gt;
        &lt;_CURRENT_RATING _Code="C" _Type="Late30Days" /&gt;
        &lt;_LATE_COUNT _30Days="1" _60Days="0" _90Days="0" x_30Lates="07/14" x_60Lates="" x_90Lates="" /&gt;
        &lt;_PAYMENT_PATTERN _Data="CCC1CC" _StartDate="2014-11" /&gt;
        &lt;CREDIT_REPOSITORY _SourceType="TransUnion" x_Primary="No" _SubscriberCode="03796761" x_CDOTradelineId="153213" /&gt;
        &lt;CREDIT_REPOSITORY _SourceType="Equifax" x_Primary="No" _SubscriberCode="644FA04640" x_CDOTradelineId="153215" /&gt;
        &lt;CREDIT_REPOSITORY _SourceType="Experian" x_Primary="Yes" _SubscriberCode="1631440" x_CDOTradelineId="153216" /&gt;
      &lt;/CREDIT_LIABILITY&gt;
  </code></pre>