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 6020041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:30:37+00:00 2026-05-23T03:30:37+00:00

Im currently trying to read an XML file and populate an observable collection, but

  • 0

Im currently trying to read an XML file and populate an observable collection, but I cant see what im doing wrong here, every time I look in the reader the xml nodes are empty

This code loads the XML file into the Xelement and I can see the data is correct.

   StreamResourceInfo xml = Application.GetResourceStream(new Uri("/WindowsPhoneDataBoundApplication1;component/Cookies.xml", UriKind.Relative));

   XElement appDataXml;   
   // Get a stream to the XML file which contains the data and load it into the XElement. 
   appDataXml = XElement.Load(xml.Stream);

This seems to be where things are going wrong for me:

    foreach (XNode n in appDataXml.Elements())
    {
        ViewModels.Cookie tempCookie = new ViewModels.Cookie();

        XmlReader reader = n.CreateReader();

        while (reader.Read())
        {
            if (reader.Name == "Name")
            {
                tempCookie.Name = reader.Value.ToString();
            }
        }
        _cookieList.Add(tempCookie);
    }

If anyone can point me in the right direction id be really gratefull.
thanks.

Edit: Here is my XML file

<?xml version="1.0" encoding="utf-8" ?>
  <Cookies>
    <Cookie>
      <Name>Almond Cookies</Name>
      <Description>Cookies With Almonds</Description>
      <Ingredients>
        <Ingredient Name ="Unsalted Butter (Room Temperature)"
                    Amount="1 Cup" 
                    Alternate="2 Sticks"/>
        <Ingredient Name ="Granulated Sugar"
                    Amount="1 Cup" />
        <Ingredient Name ="Large Eggs"
                    Amount="2" />
        <Ingredient Name ="Canned Almond Filling"
                    Amount="1 Cup" />
        <Ingredient Name ="Whole Milk"
                    Amount="1/4 Cup" />
        <Ingredient Name ="All Purpose Flour"
                    Amount="3 Cups" />
        <Ingredient Name ="Baking Soda"
                    Amount="1/2 Teaspoon" />
        <Ingredient Name ="Salt"
                    Amount="1/4 Teaspoon" />
        <Ingredient Name ="Sliced Blanched Almonds"
                    Amount="1/4 Cup" />
      </Ingredients>
      <Temperature>
        <GasMark></GasMark>
        <C></C>
        <F>350</F>
      </Temperature>
    <Duration>15</Duration>
    <Instructions>
      <Line>Preheat the oven to 350F</Line>
      <Line>In a mixing bowl cream butter and sugar till smooth. Add Eggs and blend. Add almond filling and milk and Blend again.</Line>
      <Line>In a seperate bowl mix flour,baking soda and salt. Add to the creamed mixture.</Line>
      <line>Scoop 2 rounded tablespoons of dough and roll to form each cookie. Drop dough onto lightly greased or nonstick cookie sheets, spacing the cookies 2 inches apart. Press sliced almonds onto tops</line>
      <Line>Bake untill cookies are lightly golden and firm to touch, about 15 minutes. Using a spatula transfer cookies to rack and leave to cool.</Line>
    </Instructions>
    <MakesQty>28</MakesQty>
    <ContainsNuts>False</ContainsNuts>
  </Cookie>
</Cookies>
  • 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-05-23T03:30:38+00:00Added an answer on May 23, 2026 at 3:30 am
    foreach (XElement cookie in appDataXml.Elements())
    {
        ViewModels.Cookie tempCookie = new ViewModels.Cookie();
        tempCookie.Name = cookie.Element("Name").Value;
    
        _cookieList.Add(tempCookie);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to read in an XML file, make some minor changes (alter
I'm currently trying to READ XML file from the client machine where the user
I am currently trying to read from an xml file which records the jobs
I'm currently trying to read the contents of an XML file into a Map
I am currently trying to load a slightly large xml file into a dataset.
Trying to read into an object the following XML file (can be changed) into
I am trying to read an XML file in bytes and decode it. The
I am trying to have PHP read an XML file and then convert it
I am trying to read an XML-file from another server. However the the company
I'm trying to read an xml file into memory, add a node, then write

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.