none
My XML Schema, XML, and DataSet Won't Coexist in Peace RRS feed

  • Question

  • I've searched far and wide for an answer to this and have come up with nothing that has worked.

    I'm writing middleware to talk to a third party vendor and I'm trying to get their XML and XML Schema to play nice with a DataSet. Sounds easy right? I hope someone will think so.

    Here is a sample block of the XML:

    Code Block

        <questions>
            <question>
            <prompt>Q1</prompt>
            <type>TEST1</type>
                <answer>Q1A1</answer>
                <answer>Q1A2</answer>
                <answer>Q1A3</answer>
                <answer>Q1A4</answer>
                <answer>Q1A5</answer>
                <answer>Q1A6</answer>
            </question>

            <question>
            <prompt>Q2</prompt>
            <type>TEST2</type>
                <answer>Q2A1</answer>
                <answer>Q2A2</answer>
                <answer>Q2A3</answer>
                <answer>Q2A4</answer>
                <answer>Q2A5</answer>
                <answer>Q2A6</answer>
            </question>

            <question>
            <prompt>Q3</prompt>
            <type>TEST3</type>
                <answer>Q3A1</answer>
                <answer>Q3A2</answer>
                <answer>Q3A3</answer>
                <answer>Q3A4</answer>
                <answer>Q3A5</answer>
                <answer>Q3A6</answer>
            </question>
        </questions>


    Here is a sample block of the XML Schema:

    Code Block

    <xs:element name="questions" maxOccurs="1" minOccurs="0">
      <xs:complexType>
        <xs:sequence maxOccurs="unbounded" minOccurs="0">
          <xs:element name="question">
            <xs:complexType>
              <xs:sequence maxOccurs="1" minOccurs="1">
                <xs:element name="prompt" type="xs:string" maxOccurs="1" minOccurs="1" />
                <xs:element name="type" type="xs:string" maxOccurs="1" minOccurs="1" />
                <xs:sequence maxOccurs="6" minOccurs="6">
                  <xs:element name="answer" type="xs:string" />
                </xs:sequence>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:element>


    I've bolded the trouble areas. I'm using the ReadXmlSchema() and ReadXml() method of populating my DataSet and always the 'question' DataTable generated has only 3 columns (prompt, type, and answer).

    This makes perfect sense because you can't have more than one column with the same name.

    My unfortunate task is finding a way around it. Any help will be greatly appreciated.

    Tuesday, November 13, 2007 10:44 PM

Answers

All replies