我目前有一個XElement。我使用它來打印:解析XElement - 獲取元素
System.Diagnostics.Debug.WriteLine(hostedServices);
結果:
<HostedServices xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HostedService>
<Url>url</Url>
<ServiceName>testcloudservice2</ServiceName>
<HostedServiceProperties>
<Description>New cloud service</Description>
<Location>West Europe</Location>
<Label>dGVzdGNsb3Vkc2VydmljZTI=</Label>
<Status>Created</Status>
<DateCreated>2013-04-02T09:40:27Z</DateCreated>
<DateLastModified>2013-04-02T09:40:26Z</DateLastModified>
<ExtendedProperties />
</HostedServiceProperties>
</HostedService>
<HostedService>
<Url>url</Url>
<ServiceName>testtesttest123445</ServiceName>
<HostedServiceProperties>
<Description>New cloud service</Description>
<Location>West Europe</Location>
<Label>dGVzdHRlc3R0ZXN0MTIzNDQ1</Label>
<Status>Created</Status>
<DateCreated>2013-04-02T09:30:34Z</DateCreated>
<DateLastModified>2013-04-02T09:30:34Z</DateLastModified>
<ExtendedProperties />
</HostedServiceProperties>
</HostedService>
</HostedServices>
我想獲得每<HostedService>
的服務名稱和說明。我怎樣才能得到這些?
我相信所有的服務都有名字:)我認爲你的解決方案也是正確的,只要流利的語法,我的+1返回 –