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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:26:05+00:00 2026-05-23T14:26:05+00:00

We store static data in an XML file with different groupings of data. The

  • 0

We store static data in an XML file with different groupings of data. The file is actually quite large and I’ve pared it down for this question. Each of these are a small subset of their data.

<?xml version="1.0" encoding="utf-8" ?>
<datasets>
    <dataset id="USRegions">
        <record code="SoCal">Southern California</record>
        <record code="NoCal">Northen California</record>
    </dataset>
    <dataset id="Countries">
        <record code="US" callingcode="1|US">United States</record>
        <record code="CA" callingcode="1|CA">Canada</record>
        <record code="GB" callingcode="44|GB">United Kingdom</record>
        <record code="MX" callingcode="52|MX">Mexico</record>
    </dataset>
</datasets>

For purposes of validation I want to make sure that the passed in country code, “US” for example, exists in the static data. I can get to the recordset with this query, but I’m stumped on how to drill deeper into the data.

var dataset = from record in _xAddressData.Descendants("dataset")
          where (string) record.Attribute("id") == "Countries"
          select record.DescendantNodes();
  • 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-23T14:26:06+00:00Added an answer on May 23, 2026 at 2:26 pm

    One approach:

    static bool HasCountry(this XDocument document, string country)
    {
        return document.Root.Elements("dataset")
                            .Any(d => (string)d.Attribute("id") == "Countries"
                              && d.Elements("record")
                                  .Any(r => (string)r.Attribute("code") == country));
    }
    

    Used like:

    var hasUS = _xAddressData.HasCountry("US");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large amount of data stored in an XML file, 173 MB
In what segment (.BSS, .DATA, other) of an executable file are static variables stored
How can I store a version number in a static library (file.a) and later
I am trying to parse the following XML file in Java and to store
For a scoreboard, i store the scores in an xml file. (WPF application) Of
I have a large amount of static data that needs to offer random access.
I am doing parsing on xml file and fetched data from xml file and
In my project I have to manage large quantity of static text data(ie no
I store serialized data in the registry. I want to use a foreach loop
When I parse following XML and store it in HashMap the message is cut

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.