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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:11:46+00:00 2026-06-17T04:11:46+00:00

I have this code to read XML file from isolated storage to ListBox: using

  • 0

I have this code to read XML file from isolated storage to ListBox:

using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
        {
            using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("People2.xml", FileMode.Open, isoStore))
            {
                XDocument loadedCustomData = XDocument.Load(isoStream);
                var filteredData = from c in loadedCustomData.Descendants("person")
                                   select new Person()
                                   {
                                       Name = c.Attribute("name").Value,
                                       Beneficiary = c.Attribute("beneficiary").Value,
                                       Price = c.Attribute("price").Value,
                                       Deadline = c.Attribute("deadline").Value,
                                       Index = c.Attribute("index").Value,
                                       Description = c.Attribute("description").Value

                                   };

                listBox.ItemsSource = filteredData;
            }
        }

But when I execute it against this XML

<?xml version="1.0" encoding="utf-8" ?>
<people>
    <person id="2"
            name="przyklad"
            price="850"
            deadline="22.10.12"
            beneficiary="asdasd"
            description="xxx" />
</people>

I have this error:

NullReferenceException

In this code fragment:

select new Person()
                               {
                                   Name = c.Attribute("name").Value,
                                   Beneficiary = c.Attribute("beneficiary").Value,
                                   Price = c.Attribute("price").Value,
                                   Deadline = c.Attribute("deadline").Value,
                                   Index = c.Attribute("index").Value,
                                   Description = c.Attribute("description").Value

                               };

Do you know what can help?

  • 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-17T04:11:47+00:00Added an answer on June 17, 2026 at 4:11 am
    <?xml version="1.0" encoding="utf-8" ?>
    <people>
        <person id="2" name="przyklad" price="850" deadline="22.10.12" beneficiary="asdasd" description="xxx" />
    </people>
    

    There is no index attribute on your XML, so following line is the reason of you exception:

    Index = c.Attribute("index").Value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how to read the multiple values from XML file using perl script? i have
I have to read 100.000 rows from database, I use this code : List<elementClass>
Ignoring unsafe code, .NET cannot have memory leaks. I've read this endlessly from many
I have this very simple python code to read xml for the wikipedia api:
I have created new class to read the data from xml file, which looks
I am using lxml to read my xml file. I am using a code
I have a list of object properties read from xml file and want to
I have a text read from a XML file stored in UTF8 encoding. C#
I have this method to get xml file from google reader with the contens
I have this very simple peace of code and a simple XML file .

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.