Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9257767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:14:12+00:00 2026-06-18T12:14:12+00:00

I’ve developed code like this: String resultString = await response.Content.ReadAsStringAsync(); Stream resultStream = await

  • 0

I’ve developed code like this:

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;
}

Now the resultString and resultStream come from HttpClient reposnse. I get the response from an Azure blob REST service (listing), like this:

<EnumerationResults>
    <Blobs>
        <Blob>
            <Name></Name>
            <Url></Url>
            <Properties></Properties>
         </Blob>
         <Blob>
            <Name></Name>
            <Url></Url>
            <Properties></Properties>
         </Blob>
    </Blobs>
</EnumerationResults>

With my code, I’ve managed to get an IEnumerable<XNode> from <Blobs> BUT I can’t get to Name and Url inside the <Blob> element. I get all of it as a string in one line. How do I need to change my code to get each <Blob> and get from it <Name> and <Url>?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:14:13+00:00Added an answer on June 18, 2026 at 12:14 pm

    Well to start with, once you’ve loaded the document, you can just use the Root property to get at the root element. You can then get each Blob element using Descendants or via multiple calls to Elements. You can do that outside the foreach loop though:

    var doc = XDocument.Load(resultStream);
    var allBlobs = doc.Root.Elements("Blobs").Elements("Blob");
    

    or
    var doc = XDocument.Load(resultStream);
    var allBlobs = doc.Root.Descendants(“Blob”);

    Now when you iterate over each blob, you can just get the name element using Element again, and get the text content of the element by using the explicit string conversion

    foreach (var blob in allBlobs)
    {
        var nameElement = blob.Element("Name");
        var nameText = (string) nameElement;
        ...
    }
    

    Obviously that can be done as a single statement – I just wanted to keep them separate for clarity. You can then do the same for the URL. Using the string conversion gives you a null reference if the element is missing, whereas using the Value property will give you a NullReferenceException unless you guard against it. Which is more appropriate depends on your use case.

    An alternative approach is to do all the extraction outside your foreach loop, in a query:

    var data = doc.Root.Elements("Blobs").Elements("Blob")
                  .Select(blob => new {
                      Name = (string) blob.Element("Name"),
                      Url = (string) blob.Element("Url");
                  });
    

    Then:

    foreach (var item in data)
    {
        // Use item.Name and item.Data in here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I am using JSon response to parse title,date content and thumbnail images and place
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.