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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:50:11+00:00 2026-06-02T05:50:11+00:00

I have derived a class which will take an XML file and generate ExpandoObject

  • 0

I have derived a class which will take an XML file and generate ExpandoObject dynamically for the XML being passed in utilizing Lists of ExpandoObjects and recursion.

Passing this back to be processed to retrieve data works, but the XML that I am retrieving from a legacy system is inconsistent. I can either get back a single node as such

<test>
 <insured>
  <a>BLAH BLAH BLAH</a>
  <b>BLAH BLAH BLAH</b>
  <c>BLAH BLAH BLAH</c>
 </insured>
</test>

or

<test>
 <insured>
  <a>BLAH BLAH BLAH</a>
  <b>BLAH BLAH BLAH</b>
  <c>BLAH BLAH BLAH</c>
 </insured>
 <insured>
  <a>BLAH BLAH BLAH</a>
  <b>BLAH BLAH BLAH</b>
  <c>BLAH BLAH BLAH</c>
 </insured>
 <insured>
  <a>BLAH BLAH BLAH</a>
  <b>BLAH BLAH BLAH</b>
  <c>BLAH BLAH BLAH</c>
 </insured>
</test>

So for the key ‘insured’ I am either getting an ExpandoObject or List<ExpandoObject>. I am trying to determine the simplest solution to determine the type being returned.

Ideally just something like x.insured.OfType<List<ExpandoObject>>() to return a bool or something of that nature.

Cheers

  • 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-02T05:50:13+00:00Added an answer on June 2, 2026 at 5:50 am

    Looks like you may have resolve this with Jon Skeet’s help, but in case you’re wondering, you can use the is operator for this:

    if(x.insured is List<ExpandoObject>) {
        foreach(dynamic item in x.insured) {
            DoSomething(item);
        }
    } else {
        DoSomething(x.insured);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a superclass which instantiates my Sql class so all derived classes will
I have a base Entity class which will be derived in more than a
A base class have readonly field of type List<SomeEnum> which the derived classes will
I have created a custom class derived from Canvas, which contain elements which will
I have a base and derived class called Node which form elements of a
I have a class which is derived from a base class, and have many
I have a class, say DerivedBindingList<T> , which is derived from BindingList<T> . I
I have a some code that gets passed a class derived from a certain
I'm developing an application which will have these classes: class Shortcut { public string
I have base-class Base from which is derived Derived1 , Derived2 and Derived3 .

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.