DataTable ReadXmlSchema and ReadXml Resulting in error

Posted by MasterMax1313 on Stack Overflow See other posts from Stack Overflow or by MasterMax1313
Published on 2010-04-07T23:37:53Z Indexed on 2010/04/07 23:43 UTC
Read the original article Hit count: 409

Filed under:
|
|

I'm having some trouble with the ReadXmlSchema and ReadXml methods for a DataTable. I'm getting the error "DataTable does not support schema inference from Xml".

Code Snippet: I've tried

Table.ReadXmlSchema(new StringReader(File.ReadAllText(XsdFilePath)));
Table.ReadXml(new StringReader(File.ReadAllText(XmlFilePath)));

And

Table.ReadXmlSchema(XsdFilePath);
Table.ReadXml(XmlFilePath);

Xml Snippet:

<ScreenSets>
  <ScreenSet id="Credit 1">
    <Screen xmlFile="sb-credit1.en.xml" tabText="Recommendation" isCached="false">
      <Buttons>
        <Button id="btnClosePresentation"/>
      </Buttons>
    </Screen>
  </ScreenSet>
  <ScreenSet id="Credit 2">
    <Screen xmlFile="sb-credit2.en.xml" tabText="Recommendation" isCached="false">
      <Buttons>
        <Button id="btnClosePresentation"/>
      </Buttons>
    </Screen>
  </ScreenSet>
  <ScreenSet id="Credit 3">
    <Screen xmlFile="sb-credit3.en.xml" tabText="Recommendation" isCached="false">
      <Buttons>
        <Button id="btnClosePresentation"/>
      </Buttons>
    </Screen>
  </ScreenSet>
</ScreenSets>

Xsd:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="ScreenSets">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="ScreenSet">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Screen">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Buttons">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="Button">
                            <xs:complexType>
                              <xs:attribute name="id" type="xs:string" use="required" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="xmlFile" type="xs:string" use="required" />
                  <xs:attribute name="tabText" type="xs:string" use="required" />
                  <xs:attribute name="isCached" type="xs:boolean" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="id" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

© Stack Overflow or respective owner

Related posts about datatable

Related posts about Xml