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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:08:31+00:00 2026-05-23T22:08:31+00:00

I am using DataSet.ReadXmlSchema() to construct a dataset, and DataSet.ReadXml() to load the data.

  • 0

I am using DataSet.ReadXmlSchema() to construct a dataset, and DataSet.ReadXml() to load the data.

I am then binding to the dataset to edit the data. I want to control inserting and deleting of rows in the tables in the dataset, based on the minOccurs and maxOccurs properties defined in my schema.

I have tried loading the schema below into an instance of XmlSchema, e.g. MySchema. Given that minOccurs and maxOccurs default to 1, unless otherwise specified, the LastName and FirstName nodes should occur exactly once. Contacts can occur 0 or 1 times, and ContactName can occur 0 to 10 times.

Once the XmlSchema instance is created, how can I reference the minOccurs and maxOccurs properties for the nodes?

I have found that the XmlSchemaParticle class contains MinOccurs and MaxOccurs properties, but I haven’t been able to figure out how to navigate through the XmlSchema instance to find them.

I’ve tried looking at MySchema.Items, but that doesn’t seem to contain the information.

Is this even the “best” approach? Any suggestions would be greatly appreciated.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Person.xsd" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Person">
    <xs:complexType>
      <xs:sequence>
        <!--Required Nodes-->
        <xs:element name="LastName" type="xs:string"/>
        <xs:element name="FirstName" type="xs:string"/>
        <!-- Optional Nodes-->
        <xs:element name="Contacts" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="ContactName" minOccurs="0" maxOccurs="10">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string"/>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Does anyone know how I can find the MinOccurs/MaxOccurs values from an instance of XmlSchema? I have read the documentation at MSDN, and also tried navigating the class through the Visual Studio debugger, but I can not find the correct properties for these values.

  • 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-23T22:08:32+00:00Added an answer on May 23, 2026 at 10:08 pm

    I don’t think that the DataSet will respect minOccurs/maxOccurs.

    In fact, DataSet does not map one-to-one to XML Schema. The DataSet class maps to a relational database model. Anything in XML Schema that doesn’t map to that model will be ignored or transformed by DataSet.

    An example was a case where I had elements of the same complex type as child elements of two different parents. I was able to read that schema into the DataSet, but DataSet in effect created a copy of my shared complex type, in order to match the Relational model. The XML schema I wrote back out did not match the schema I read in.

    You should try writing out the schema using WriteXmlSchema and compare it to the schema you read in.

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

Sidebar

Related Questions

I'm loading data into a DataSet from an XML file using the ReadXml method.
I have a problem with binding data using BindingSource, typed dataset and DataGridView. My
I have a form with a DataGridView and I want to load data from
im populating the data in the combo box using dataset tables...with some table name..now
I'm reading a string into a DataSet using the ReadXML method. When I try
I am using a dataset to pull data from a DB. One of the
I am using a DataSet (please do not ask why) with Oracle data provider
I've just started using a DataSet at work and source control is a nightmare
I have an xml file and I am loading it in DataTable using DataSet.ReadXML.
I'm trying to create a DLL using a Dataset.XSD file to access my website's

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.