我开发了这样的代码:
String resultString = await response.Content.ReadAsStringAsync();
Stream resultStream = await response.Content.ReadAsStreamAsync();
XElement rootElement = XDocument.Load(resultStream).Elements().First();
XElement blobs = rootElement.Element("Blobs");
foreach (var blob in blobs.Elements("Blob"))
{
var t = blob;
}
现在resultString和resultStream来自HttpClient reposnse。我从 Azure blob REST 服务(列表)获得响应,如下所示:
<EnumerationResults>
<Blobs>
<Blob>
<Name></Name>
<Url></Url>
<Properties></Properties>
</Blob>
<Blob>
<Name></Name>
<Url></Url>
<Properties></Properties>
</Blob>
</Blobs>
</EnumerationResults>
使用我的代码,我设法IEnumerable<XNode>从<Blobs>但我无法进入元素内部Name。我将所有这些都作为一个字符串放在一行中。我如何需要更改我的代码以获取每个并从中获取?Url<Blob><Blob><Name><Url>