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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:54:04+00:00 2026-05-16T21:54:04+00:00

The Problem I have an issue when I deserialize my xml, one of the

  • 0

The Problem

I have an issue when I deserialize my xml, one of the child elements is not being deserialized. It is null in the class instance despite being populated in the xml.

A little Background

I used XsdObjectGenerator to create poco classes based on my .xsd. I was then able to deserialize the xml into a class instance and work with the objects.

I modifed the autogenerated classes by wrapping them in a namespace called ‘TFS’.

At a certain point in the project, I found it necessary to place one of the child elements in it’s own namespace called ‘COM’.

The next time I attempted to deserialized the xml into a class instance, the child element is not being deserialized.

Here is the pertinent snippet of TFS class code with the child element namespace changed to COM. It also includes the parent element OrdDtl which remains in the TFS namespace.

[XmlRoot(ElementName="OrdDtl",Namespace=Declarations.SchemaVersion,IsNullable=false),Serializable]
    public class OrdDtl
    {
            [XmlElement(Type=typeof(COM.AcctSetup), ElementName="AcctSetup", IsNullable=false, Form=XmlSchemaForm.Qualified, Namespace = Declarations.SchemaVersion)]
        [EditorBrowsable(EditorBrowsableState.Advanced)]
            public COM.AcctSetup __AcctSetup;

        [XmlIgnore]
            public COM.AcctSetup AcctSetup
        {
            get
            {
                if (__AcctSetup == null) __AcctSetup = new COM.AcctSetup();     
                return __AcctSetup;
            }
            set {__AcctSetup = value;}
        }

Here is the AcctSetup declaration in the COM namespace which is contained in it’s own file:

[XmlRoot(ElementName = "AcctSetup", Namespace = Declarations.SchemaVersion, IsNullable = false), Serializable]
    public class AcctSetup
    {
......
}

and here is my deserialize function:

public static T XMLStringToXMLObject<T>(string pXmlString)
    {
        T retVal = default(T);   

        try
        {
            XmlSerializer vSerializer = new XmlSerializer(typeof(T));
            MemoryStream vMemoryStream = new MemoryStream(StringToUTF8ByteArray(pXmlString));
            XmlTextWriter vXmlTextWriter = new XmlTextWriter(vMemoryStream, Encoding.UTF8);
            retVal = (T)vSerializer.Deserialize(vMemoryStream);
        }
        catch (System.Exception ex)
        {
            if (ExceptionMain.LogException(ex))
                throw;
        }

        return retVal;
    }

Any assistance in getting the COM.AcctSetup element to deserialize is very much appreciated. Let me know if you need additional info or code samples.

  • 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-05-16T21:54:05+00:00Added an answer on May 16, 2026 at 9:54 pm

    I figured this out. The xml file I was attempting to deserialize contained the following attribute in the root element:

    xmlns="tfs"
    

    Therefore every element in the xml file was under this xml namespace.

    My changes to the code were essentially putting the AcctSetup element under a separate xml namespace ‘com’. Therefore in order to deserialize a file, the file would need the ‘xmlns=”tfs”‘ in the root element and a separate ‘xmlns=”com”‘ attribute on the acctsetup child attribute.

    Since this was not the format of the file I was receiving on the parent elements above the AcctSetup element were deserialized into the class instance.

    My solution was to move the ‘acctsetup’ element back into the ‘tfs’ namespace again. In my particular situation the only downside is a slight bit of code duplication – but everything works again.

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

Sidebar

Related Questions

Possible Duplicate: Css z-index problem I have an issue where one image is infront
I have an issue with a string compare problem... lets say: string a =
I have a problem and I will try to explain the issue: I have
I have problem with my widget related to performance and memory: Issue : My
I have an issue that seems like very flaky behavour, is this a problem
I have this issue with ComboBox that uses IEnumerable<Brush> as ItemsSource; the problem lies
I have a problem with the jQuery UI Slider. The issue also appears on
Continuing my problem from yesterday, the Silverlight datagrid I have from this issue is
I have a little problem with javascript form submit issue, here is the script
My problem/issue We are working on an opensource project which we have hosted on

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.