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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:36:47+00:00 2026-05-17T00:36:47+00:00

I am trying to extract data from XML. I generated C# classes using XSD

  • 0

I am trying to extract data from XML. I generated C# classes using XSD of this XML file. I am trying to get the data from XML file and save it C# class.
I am running into NULLReferenceException Was Unhadled by User; “Object reference not set to an instance of an object.” error.

My XML File

<clue_personal_auto xmlns = "http://cp.com/rules/client"> 
<admin> 
<quoteback name="trackingNUmber">67890 </quoteback>
</admin> 
<report> 
    <inquiry_processing_summary>
    <classification> inqiury </classification>
    </inquiry_processing_summary>
    <results_dataset>
      <claims_history type="Subject Section">
      <claim id = "s1" unit-number="1" sequence-number="1" number="11111">
      <scope_of_claim>Full Scope</scope_of_claim>
      <claim_date>05/19/2005</claim_date>
      <claim_age years="1" months="10"/>
      <clue_file_number>222221</clue_file_number>
      <policy number="XX111111">
          <issuer> CUSTOMER TEST </issuer>
          <auto_type> Personal Auto</auto_type>
          <fsi_issuer>Field absent on inquiry</fsi_issuer>
       </policy>
       <subject classification="POlicy HOlder">
         <name>
         <first>SADIE</first>
         <last>DOE</last>
         <fsi_first>Discrepancy</fsi_first>
         <fsi_middle>Field absent on inquiry and rport</fsi_middle>
         <fsi_last>Match</fsi_last>
         <fsi_suffix>Field absent on inquiry and report</fsi_suffix>
        </name>
        <ssn>123456789</ssn>
        <driversLicense number="999999999" state="GA">
        <fsi_state>Field abscent on inquiry</fsi_state>
        <fsi_number>Field absent on inquiry</fsi_number>
        </driversLicense>
        </subject>
        <claimPayment amount_paid="2841.00" type="Collision" disposition="Open"/>
        <claimPayment amount_paid="0.00" type="Physical/Property Damage" disposition="Open"/>
        <claim_association_indicator>Indicates the Vehicle Operator was the person matched </claim_association_indicator>
        <vehicle>
         <model_year>1995</model_year>
         <model_make>Nissan Sentra</model_make>
         <vin> 9N9ABC99D434kjlkfajsdkl</vin>
         <disposition>Not Reported </disposition>
         <fsi_model_year>Field absent on inquiry and report</fsi_model_year>
         <fsi_model_make>Field absent on inquiry and report</fsi_model_make>
         <fsi_vin>Field absenton inquiry and report</fsi_vin>
         </vehicle>
        </claim>
      <claim id = "s2" unit-number="2" sequence-number="2" number="22222">
        <scope_of_claim>Limited scope</scope_of_claim>
      </claim>
      <claim id = "s3" unit-number="3" sequence-number="3" number="33333">
      </claim>
      </claims_history>
      <inquiry_history name ="GO America" id="1" date="09/10/2010"/>
     </results_dataset>
</report> 

My query :

  List<results_dataset> resultdatasets =
    (from b in query.Descendants(xmlns + "results_dataset")
      select new results_dataset
          {
           claimsHistory = 
                     (from c in query.Descendants(xmlns + "claims_history")
                      select new Claims_history
                         {
                           claim = (from d in query.Descendants(xmlns + "claim")
                              select new Claim () 
                               {
                               policy = ( from e in query.Descendants(xmlns + "policy")
                                          **select new cluePolicyType()
                                            {
                                             issuer = e.Element("issuer").Value ,
                                             number = e.Attribute("number").Value ,
                                             auto_type = e.Element("auto_type").Value,
                                             fsi_issuer= e.Element("fsi_issuer").Value,
                                           } **
                                        ).ToList(),
                             scope_of_claim = d.Element("scope_of_claim").Value,
                             type = c.Attribute("type").Value

                           }).ToList()
                 }
         ).ToList();

The area in between ******** is where I get this error.If I remove the code which is inside the {} area of ******** then no error. I am not able to figure it out. it is driving me crazy.

  • 1 1 Answer
  • 2 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-17T00:36:48+00:00Added an answer on May 17, 2026 at 12:36 am

    So you’ve reduced the problem to these lines:

    issuer = e.Element("issuer").Value ,
    number = e.Attribute("number").Value ,
    auto_type = e.Element("auto_type").Value,
    fsi_issuer= e.Element("fsi_issuer").Value
    

    Without being able to test your code, my guess is that the Element or Attribute (issuer/number/auto_type/fsi_issuer) simply doesn’t exist for some of your elements. If a specified attribute is not found, it will return null, which will throw your NRE when you resolve .Value.

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

Sidebar

Related Questions

I am trying to extract data from xml file that looks like this (see
I am trying to extract data from XML file and save it my C#
I am trying to extract data from a xml file, get rid of the
I'm trying to extract data from an xml file. A sample of my code
After giving up on PHP I'm trying to extract data from the xml using
I'm trying to extract some information from an xml file using xslt. I've used
I'm trying to extract some data from XML using Linq to XML, and I
I'm trying to extract data from an xml file. The problem is I know
I am trying to get the data from input xml message using functoids. But
I'm trying to get data from a webpage that serves a XML file periodically

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.