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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:36:31+00:00 2026-06-15T12:36:31+00:00

My xml: <Configuration> <LaunchDebugger>false</LaunchDebugger> <RequestFolder>./Request</RequestFolder> <ResponseFolder>./Response</ResponseFolder> <Countries> <Country NumericCode=1FH FileName=file1.xml>1</Country> <Country NumericCode=20H FileName=file2.xml>2</Country> <Country

  • 0

My xml:

  <Configuration>
    <LaunchDebugger>false</LaunchDebugger>
    <RequestFolder>./Request</RequestFolder>
    <ResponseFolder>./Response</ResponseFolder>
    <Countries>
      <Country NumericCode="1FH" FileName="file1.xml">1</Country>
      <Country NumericCode="20H" FileName="file2.xml">2</Country>
      <Country NumericCode="" FileName="file3.xml">3</Country>
    </Countries>
  </Configuration>

Country class:

public class Country
{
    public String Name { get; set; }
    public String NumericCode { get; set; }
    public String FileName { get; set; }
}

This is how i create objects from it using LINQ:

    CountryList = (from filter in Configuration.Descendants("Countries").Descendants("Country")
                    select new Country() 
                    {
                        Name = (string)filter.Value,
                        NumericCode = (string)filter.Attribute("NumericCode"),
                        FileName = (string)filter.Attribute("FileName")
                    }).ToList();

Parsing xml works, i get all 3 countries in my list, but i also get one extra null object as the last item of the list.

enter image description here

Any idea why that would be happening?

  • 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-15T12:36:31+00:00Added an answer on June 15, 2026 at 12:36 pm

    Reason is simple – List<T> has default capacity equal to 4. Capacity gets or sets the total number of elements the internal data structure can hold without resizing. Internal data structure is a simple array private Country[] _items, which is initially has length equal to 4. Thus there is reserved place for forth element, which is null until element assigned. But don’t worry – elements count will be 3 if you check.

    Here is an image, which shows both public (three items) and internal data structure (array of capacity size)

    Internal structure of List

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Application1 has a xml configuration file say: <Application1> <ConfigApp1>Value1</ConfigApp1> <App1Layout>Layout</App1Layout> </Application1> Application2 has a
Using the xml configuration of log4cxx (which is identical in configuration to log4j). I
To use Spring Integration in a Spring XML configuration file, I need to declare
I have the following log4j.xml configuration: <log4j:configuration> <appender name = CONSOLE class = org.apache.log4j.ConsoleAppender>
Is it possible to convert the following XML configuration to an annotation based one?
I'm looking for ways of getting rid of Windsor Xml configuration files. I want
I've been asked to write some scripts that read in XML configuration files that
I know I can add service behaviors with some XML configuration, but I'd like
In short, what works faster: SessionFactory precompiling XML configuration, or Fluent NHibernate providing configuration
I'm wondering whats the easiest way to change some settings in tomcats conf/server.xml configuration

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.