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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:28:15+00:00 2026-05-10T19:28:15+00:00

I have the following xml I’d like to deserialize into a class <?xml version=1.0

  • 0

I have the following xml I’d like to deserialize into a class

<?xml version='1.0' encoding='utf-8' ?> <root>   <element1>String1</element1>   <element2>String2</element2> </root> 

I am trying to serialize it into the following class:

    [XmlRoot('root')]     public class root     {         [XmlElement('element1')]         internal string element1 { get; set; }          [XmlElement('element2')]         internal string element2 { get; set; }     } 

When I try deserializing it using the following code, the config object is instantiated, but the strings are null.

     using (TextReader reader = new StreamReader(configFile))         {             XmlSerializer serializer = new XmlSerializer(typeof(root));             this.config = (root)serializer.Deserialize(reader);         } 

I’ve tried using xsd.exe to create an xsd, and then create a class based off of that, but there is too much clutter generated by that tool. I think I’m close here. What am I missing?

  • 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. 2026-05-10T19:28:15+00:00Added an answer on May 10, 2026 at 7:28 pm

    You can’t serialise/deserialise internal properties – They have to be public.

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

Sidebar

Related Questions

i have following xml : <?xml version=1.0 encoding=UTF-8 standalone=no?> <root> <processid>processid_1111</processid> <suggestion> <geo1>a</geo1> <geo2>b</geo2>
I have the following XML layout for a ListActivity. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have the following XML example: <?xml version=1.0 encoding=UTF-8?> <OpenSearchDescription xmlns=http://a9.com/-/spec/opensearch/1.1/ xmlns:custom=http://example.com/opensearchextensions/1.0/> <ShortName>Test</ShortName> <Description>Testing....</Description>
I have the following XML: <?xml version=1.0 encoding=utf-8?> <ArrayOfTrafficResponseIncident xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema> <TrafficResponseIncident> <IncidentReportId>220</IncidentReportId> <IncidentNumber>137</IncidentNumber>
I have the following xml: <?xml version=1.0 encoding=utf-8 ?> <AAA> <BBB CCC=it is aatr
I have the following XML: <?xml version=1.0 encoding=utf-8 ?> <ApplicationSettingCategories> <Category>Cat1</Category> <Category>Cat2</Category> <Category>Cat3</Category> <Category>Cat4</Category>
I have the following xml: <?xml version=1.0 encoding=utf-8 ?> <ROLES> <ROLE type=A> <USER name=w
I have the following Xml in my Resources.xmltest: <?xml version=1.0 encoding=utf-8 ?> <Response xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
I have the following xml structure: <?xml version=1.0 encoding=utf-8 ?> <administrators> <administrator> <fullname>full name1</fullname>
i have following xml <?xml version=1.0 encoding=UTF-8 ?> <Users> <User> <ID>SMSUser(63)</ID> <Email>a@example.com</Email> </User> <User>

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.