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

  • Home
  • SEARCH
  • 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 749565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:26:58+00:00 2026-05-14T14:26:58+00:00

I have a schema from a third party that I’ve generated c# objects from

  • 0

I have a schema from a third party that I’ve generated c# objects from using Xsd2Code (other options like xsd.exe, xmlspy etc either crashed or spewed 40mb of code that required their library to work)

Anyway, here’s an example of a problem element from the schema:

<xsd:schema xmlns:ns1="something" xmlns:ns2="somethinelse" targetNamespace="something">

  <xsd:complexType name="someType">
    <xsd:sequence>
      <xsd:element ref="element1" />
      <xsd:element ref="ns2:element2" />
    </xsd:sequence>
  </xsd:complexType>

 </xsd:schema>

The generated wrapper class looks like this:

[XmlType(Namespace="something")]
[XmlRoot("someType", Namespace="something", IsNullable=false)]
public partial class SomeType {
  public string Element1 { get; set; }

  [XmlElement(Namespace="somethinelse")]
  public string Element2 { get; set; }
}

Example xml using said schema:

<someType>
  <element1>SomeValue</element1>
  <ns2:element2>SomeValue2</element2>
</someType>

(Any errors are my typing the example. the schema is valid and un-changeable)

And now for the problem. when I try to deserialize the xml like so:

XmlSerializer ser = new XmlSerializer(typeof(SomeType));
XmlReader reader = XmlReader.Create(new StringReader(xmlString))
SomeType obj = (SomeType)ser.Deserialize(reader)

The generated objects serialize correctly, adding the “ns2” to elements that need it. However, when deserializing, element1 gets set and element2 is left null.

  • 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-14T14:26:59+00:00Added an answer on May 14, 2026 at 2:26 pm

    The sample data we were provided with had a typeo in the namespace which was causing it to deserialize wrong. Go figure.

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

Sidebar

Related Questions

My web service is receiving xml from a third party that looks like this:
I have an XSD which was transformed from a RELAX NG schema with a
I have a schema called application. Is there a way that, rather than using
I have the following schema (generated from an existing table with the schema module
From Day One I was told that each third-party iOS app was perfectly sand-boxed
I have to create or update a schema from some models that I have
We have a .net 3.5 web app that consumes third party web services. The
OK, so here's the background: We have a third-party piece of software that does
I have this schema which I need to match 2 rows from user_data :
I have a query like this: SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE FROM MY_DB.INFORMATION_SCHEMA.COLUMNS WHERE

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.