title: select value of attribute by linq to xml
body: <p>in my xml file how i can select the value for attributes <code>TagId</code> in <code>ServiceAssignment</code>  elements by linq to xml </p>
  
  <p><strong>Note : this xml in a String Property not in xml file</strong> </p>
  
  <pre><code>&lt;AnchoredXml xmlns="urn:schema:Microsoft.Rtc.Management.ScopeFramework.2008" SchemaWriteVersion="1"&gt;
    &lt;Key ScopeClass="Global"&gt;
      &lt;SchemaId Namespace="urn:schema:Microsoft.Rtc.Management.Settings.ServiceAssignment.2008" ElementName="ServiceAssignments" /&gt;
      &lt;AuthorityId Class="Host" InstanceId="00000000-0000-0000-0000-000000000000" /&gt;
    &lt;/Key&gt;
    &lt;Dictionary Count="1"&gt;
      &lt;Item&gt;
        &lt;Key /&gt;
        &lt;Value Signature="2ffb6b0d-0239-4016-b08b-40520d1687ff"&gt;
          &lt;ServiceAssignments xmlns="urn:schema:Microsoft.Rtc.Management.Settings.ServiceAssignment.2008"&gt;
            &lt;ServiceAssignment TagId="659550892"&gt;
              &lt;Component Name="Registrar"&gt;
                &lt;ServiceId xmlns="urn:schema:Microsoft.Rtc.Management.Deploy.Topology.2008" SiteId="1" RoleName="Registrar" Instance="1" /&gt;
              &lt;/Component&gt;
              &lt;Component Name="PresenceFocus"&gt;
                &lt;ServiceId xmlns="urn:schema:Microsoft.Rtc.Management.Deploy.Topology.2008" SiteId="1" RoleName="UserServices" Instance="1" /&gt;
              &lt;/Component&gt;
            &lt;/ServiceAssignment&gt;
            &lt;ServiceAssignment TagId="911048693"&gt;
              &lt;Component Name="Registrar"&gt;
                &lt;ServiceId xmlns="urn:schema:Microsoft.Rtc.Management.Deploy.Topology.2008" SiteId="1" RoleName="Registrar" Instance="2" /&gt;
              &lt;/Component&gt;
              &lt;Component Name="PresenceFocus"&gt;
                &lt;ServiceId xmlns="urn:schema:Microsoft.Rtc.Management.Deploy.Topology.2008" SiteId="1" RoleName="UserServices" Instance="2" /&gt;
              &lt;/Component&gt;
            &lt;/ServiceAssignment&gt;
          &lt;/ServiceAssignments&gt;
        &lt;/Value&gt;
      &lt;/Item&gt;
    &lt;/Dictionary&gt;
  &lt;/AnchoredXml&gt;
  </code></pre>
  
  <p>i try this code but give me a null exception </p>
  
  <pre><code>var MyList = doc.Root.Elements("ServiceAssignment").Select(c=&gt;c.Attribute(("TagId")).Value).ToList();
  </code></pre>