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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:20:32+00:00 2026-06-09T09:20:32+00:00

I’ve got a strange behaviour with my XML serializer. After reading an XML and

  • 0

I’ve got a strange behaviour with my XML serializer.
After reading an XML and deserializing it into an object, all properties are set to it’s default values and not to the values declared in the xml file.
The serializer doesn’t throw an exception and runs properly. The xml file is properly formed and fits to the class structure.
Anyone an idea how that can be, or how I could get to the source of the problem?
Thank you

edit:
I didn’t tell you the whole story. The thing is, the XML which I get is from another component. I was able to deserialize the XML file and now I got a diffrent format. Since the file has about 3000 lines I can’t post the whole code. But here’s the difference:
deserializable:

<?xml version="1.0" encoding="utf-8"?>
<rootElem xmlns:cfg="namespace1" xmlns:office="namespace2" xmlns="namespace3">
<Prop1 xmlns="">6</Prop1>
<Prop2 xmlns="">string</Prop2>
</rootElem>

not deserializable

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rootElem xmlns:cfg="namespace1" xmlns:office="namespace2" xmlns="namespace3">
<Prop1>6</Prop1>
<Prop2>string</Prop2>
</rootElem>

I don’t really understand why I can unmarshal the first example due to the xmlns tag inside each element and why I can’t unmarshal the second one…

edit2: just realized that just the top level elements got these strange xmlns=”” attributes. But the C# class declaration is not different from all other classes…that’s weird.

The C# class is like this:

using namespace1;

namespace namespace3
{
  [System.SerializableAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(Namespace="namespace3")]
  [System.Xml.Serialization.XmlRootAttribute(Namespace="namespace3", IsNullable=true)]
  public partial class rootElem: BaseObject
  {
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public int Prop1
    {
      //...
    }
  }
}
  • 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-09T09:20:35+00:00Added an answer on June 9, 2026 at 9:20 am

    A concrete example (both c# ad xml) would go a very long way here. Most likely one of:

    • the names aren’t an exact (case-sensitive) match between the xml and the c# (allowing for name overrides via attributes etc)
    • there is a mixup between xml attributes / elements
    • there is a difference in the xml namespaces (typically, present in the xml and missing in the c#)

    With your edit, it becomes clearer. Xml namespaces are very significant; <foo xmlns="abc"/> and <foo/> are completely unrelated. Further, xml namespaces are inherited, so in:

    <rootElem xmlns:cfg="namespace1" xmlns:office="namespace2" xmlns="namespace3">
    <Prop1>6</Prop1>
    <Prop2>string</Prop2>
    </rootElem>
    

    it is the case that Prop1 and Prop2 are in the namespace3 namespace that they inherit from their parent. To make it absolutely clear to the c# that you want those to be in the child namespace (rather than the empty namespace), tell it:

    [Serializable]
    [DesignerCategory("code")]
    [XmlType(Namespace = Namespace3)]
    [XmlRoot(Namespace = Namespace3, IsNullable = true)]
    public partial class rootElem
    {
        private const string Namespace3 = "namespace3"; // to avoid repetition
    
        [XmlElement(Namespace = Namespace3)]
        public int Prop1 { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
i got an object with contents of html markup in it, for example: string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.