从xml字符串中读取xml后代集合

时间:2015-08-30 03:49:09

标签: c# linq c#-4.0 xml-parsing linq-to-xml

<feed xml:base="http://test.table.core.windows.net/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <id>http://test.table.core.windows.net/Colors</id>
  <title type="text">Colors</title>

  <link rel="self" title="Colors" href="Colors" />
 <entry m:etag="W/"datetime'2015-08-27T10%3A59%3A47.8592342Z'"">    
    <category term="test.Colors" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" title="Colors" href="Colors(PartitionKey='AAA',RowKey='0001')" />
    <title />
    <updated>2015-08-30T03:39:10Z</updated>
    <author>
      <name />
    </author>
    <content type="application/xml">
      <m:properties>
        <d:PartitionKey>AAA</d:PartitionKey>
        <d:RowKey>0001</d:RowKey>        
        <d:ColorName>Blue</d:ColorName>
      </m:properties>
    </content>
  </entry>
 <entry m:etag="W/"datetime'2015-08-27T10%3A59%3A47.8592341Z'"">   
    <category term="test.Colors" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" title="Colors" href="Colors(PartitionKey='AAA',RowKey='1002')" />
    <title />

    <author>
      <name />
    </author>
    <content type="application/xml">
      <m:properties>
        <d:PartitionKey>AAA</d:PartitionKey>
        <d:RowKey>1002</d:RowKey>
       <d:ColorName>Blue</d:ColorName>
      </m:properties>
    </content>
  </entry>
  <entry m:etag="W/"datetime'2015-08-27T10%3A59%3A47.8592343Z'"">    
    <category term="test.Colors" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" title="Colors" href="Colors(PartitionKey='AAZ',RowKey='0111')" />
    <title />

    <author>
      <name />
    </author>
    <content type="application/xml">
      <m:properties>
        <d:PartitionKey>AAZ</d:PartitionKey>
        <d:RowKey>0111</d:RowKey>        
        <d:ColorName>Blue</d:ColorName>
      </m:properties>
    </content>
  </entry>
</feed>

如何使用C#或LINQ读取“m:properties”后代。此xml字符串存储在XElement类型的变量

0 个答案:

没有答案