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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:23:01+00:00 2026-06-17T07:23:01+00:00

I need to parse a complex and large (100 MB+) XML file. Fortunately I

  • 0

I need to parse a complex and large (100 MB+) XML file. Fortunately I have XML Schema definitions, but unfortunately I can not use xsd2code to generate an automatic XML deserialization, because there are abstract message types used on the top level of the XML.
The structure of the XML file is like this:

<Head>  
    <Batch>   
        <Dog></Dog>   
        <Dog></Dog>  
    </Batch>  
</Head>

The xsd defines batch to contain abstract animals, not dog. Xsd2Code can create the Dog class with the right XML attributes, but the dog class is inside another xsd file.
I tried to paste all xsd together, but this did not help to fix this.

Is there a good way like Linq to XML or Xpath to loop over the elements in Batch and create Dog instances without needing to parse Dog manually?

  • 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-17T07:23:02+00:00Added an answer on June 17, 2026 at 7:23 am

    Is there a good way like Linq to XML or Xpath to loop over the elements in Batch and create Dog instances without needing to parse Dog manually?

    It depends on what you mean by “manually”. I’ve found it’s useful to have a pattern where each relevant class has a static FromXElement factory method (or a constructor taking an XElement) which extracts the relevant details. With LINQ to XML that’s pretty straightforward, e.g.

    public static Dog FromXElement(XElement element)
    {
        // Or whatever...
        return new Dog((string) element.Element("Name"),
                       (double) element.Element("Weight"));
    }
    

    Then you can use:

    List<Dog> dogs = batch.Elements("Dog")
                          .Select(x => Dog.FromXElement(x))
                          .ToList();
    

    (You may be able to use Select(Dog.FromXElement) instead – it depends on which version of C# you’re using.)

    To process all the animals in a batch, you’d probably want something like:

    private static readonly Dictionary<string, Func<XElement, Animal>> Factories =
        new Dictionary<string, Func<XElement, Animal>>
    {
        { "Dog", Dog.FromXElement },
        { "Cat", Cat.FromXElement },
        // etc
    }
    ...
    List<Animal> animals = batch.Elements()
                                .Select(x => Factories[x.Name.LocalName](x))
                                .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to parse and store a somewhat (but not too) complex stream and
I want to parse a complex XML schema file and export to a C#
I have a complex situation where I need to parse a very long string.
We have a complex json structure which we need to parse in Android. {
I have a series of very complex XML files. I need to access these
I have got a valid complex json and I need to parse this json
I'm trying to parse out an complex XML file using LINQ. The files contains
I need to parse an XLIFF file using C#, but I'm having some trouble.
I have a rather complex Flat File that I'm trying to parse using SSIS.
I need to parse complex expresion from string to bool. It can only contain:

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.