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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:34:20+00:00 2026-05-12T22:34:20+00:00

This is a two part question. The first is a specific question about DataSets

  • 0

This is a two part question. The first is a specific question about DataSets and XML. The second is a more general “am I taking the right approach” type question. While I’d certainly appreciate replies that answer both questions, I’d also welcome answers that only tackle one or the other!

Question 1

Does the DataSet class support mixed complex type elements? For example, let’s say I have the following XML:

<cars>
   <car id="1">10000
     <colour>blue</colour>
     <doors>4</doors>
   </car>
</cars>

The XSD describing this XML will have a complex type with the “mixed” attribute set to true. This allows me to have the value of my car ($10,000) in plain text, following by whatever other elements I need.

However, when I convert this XML into a DataSet and back again using the following code:

StringReader sr = new StringReader(xml);
DataSet dataset = new DataSet();
dataset.ReadXml(sr);
sr.Close();

StringWriter sw = new StringWriter();
dataset.WriteXml(sw);
xml = sw.ToString();
sw.Close();

Then the resulting XML is as follows:

<cars>
   <car id="1">
     <colour>blue</colour>
    <doors>4</doors>
  </car>
</cars>

i.e. the value “10000” goes missing.

This occurs not only if I have the ReadXml() call infer the XML schema (as above), but also if I provide an XSD (eg by calling ReadXmlSchema()).

Is there any way to avoid this? Or should I just make sure I avoid mixed types?

Question 2

Are there any other limitations, such as the one outlined above, that I should be aware of when converting XML to DataSets and vice versa?

Or perhaps Question 1 indicates that I am going about things in reverse order. At the moment I am starting with the desired XML (such as the cars example above), and am converting this into a DataSet. The intention is to persist the data as XML to a database, and when I wish to display this data on a WinForm, I’ll convert the XML to a DataSet and use data binding on the various tables in the DataSet. But rather than starting with an XSD, perhaps I should be defining my data as a (typed) DataSet first, and then let the ReadXml/WriteXml methods take care of what the XML looks like?

  • 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-12T22:34:21+00:00Added an answer on May 12, 2026 at 10:34 pm

    Thank you for all of the replies. 😉

    Seeing as no one was able to help, I thought I’d attempt to answer my own question:

    Question 1 – mixed type elements are simply not allowed by the DataSet class. The only confirmation I could find on this, other than my own testing, is this MSDN forum post, where the ADO.NET program manager writes, “This behavior is by design – DataSet does not support mixed content XML/XSD.”

    Question 2 – This demonstrates the danger in starting with the XML/XSD in mind, and trying to convert that into a DataSet. This has led to us re-thinking our approach, with the aim of starting with the DataSet first and letting the XML format be derived from it, rather than the other way around.

    (Anyone else’s thoughts still welcome!)

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

Sidebar

Ask A Question

Stats

  • Questions 216k
  • Answers 216k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer SELECT history.id, task.name FROM history INNER JOIN task WHERE history.task… May 12, 2026 at 11:13 pm
  • Editorial Team
    Editorial Team added an answer You'll want to use Django's convention for joining across relationships… May 12, 2026 at 11:13 pm
  • Editorial Team
    Editorial Team added an answer From the API docs, applications targeting DONUT or higher: ...must… May 12, 2026 at 11:13 pm

Related Questions

This is kinda....a two part question. The first one is much more important than
I have two rails apps on separate virtual servers, but in the same facility.
This is actually a two part question. First,does the HttpContext.Current correspond to the current
This is a two-part question: First, I am interested to know what the best
I have a two part question. The first I think I have an okay

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.