【发布时间】:2010-04-07 23:37:53
【问题描述】:
我在使用 DataTable 的 ReadXmlSchema 和 ReadXml 方法时遇到了一些问题。我收到错误“DataTable 不支持来自 Xml 的架构推断”。
代码片段: 我试过了
Table.ReadXmlSchema(new StringReader(File.ReadAllText(XsdFilePath)));
Table.ReadXml(new StringReader(File.ReadAllText(XmlFilePath)));
和
Table.ReadXmlSchema(XsdFilePath);
Table.ReadXml(XmlFilePath);
Xml 片段:
<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>
【问题讨论】: