Created
August 29, 2014 13:33
-
-
Save pingec/336f087d4e820c4f72cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Data; | |
using System.Linq; | |
using System.Xml; | |
using System.Xml.Linq; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string xml = @"<xs:schema id=""NewDataSet"" xmlns="""" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:msdata=""urn:schemas-microsoft-com:xml-msdata"" xmlns:msprop=""urn:schemas-microsoft-com:xml-msprop""> | |
<xs:element name=""NewDataSet"" msdata:IsDataSet=""true"" msdata:MainDataTable=""row"" msdata:Locale=""""> | |
<xs:complexType> | |
<xs:choice minOccurs=""0"" maxOccurs=""unbounded""> | |
<xs:element name=""row"" msdata:Locale=""""> | |
<xs:complexType> | |
<xs:sequence> | |
<xs:element name=""AbcDocId"" msprop:DataTypeName=""int"" type=""xs:int"" minOccurs=""0"" /> | |
<xs:element name=""TypeId"" msprop:DataTypeName=""int"" type=""xs:int"" minOccurs=""0"" /> | |
<xs:element name=""AbcEventId"" msprop:DataTypeName=""int"" type=""xs:int"" minOccurs=""0"" /> | |
<xs:element name=""ApdStatusId"" msprop:DataTypeName=""int"" type=""xs:int"" minOccurs=""0"" /> | |
<xs:element name=""DocDate"" msprop:DataTypeName=""date"" type=""xs:dateTime"" minOccurs=""0"" /> | |
<xs:element name=""AbcDocKey"" msprop:DataTypeName=""nvarchar"" msprop:ColumnSize=""20"" minOccurs=""0""> | |
<xs:simpleType> | |
<xs:restriction base=""xs:string""> | |
<xs:maxLength value=""20"" /> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:element> | |
<xs:element name=""Title"" msprop:DataTypeName=""nvarchar"" msprop:ColumnSize=""200"" minOccurs=""0""> | |
<xs:simpleType> | |
<xs:restriction base=""xs:string""> | |
<xs:maxLength value=""200"" /> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:element> | |
<xs:element name=""LastUpdateDateTime"" msprop:DataTypeName=""datetime"" type=""xs:dateTime"" minOccurs=""0"" /> | |
<xs:element name=""ParentDocTypeId"" msprop:DataTypeName=""int"" type=""xs:int"" minOccurs=""0"" /> | |
<xs:element name=""LoginIdCreated"" msprop:DataTypeName=""int"" type=""xs:int"" minOccurs=""0"" /> | |
<xs:element name=""ImageIcon"" msprop:DataTypeName=""nvarchar"" msprop:ColumnSize=""128"" minOccurs=""0""> | |
<xs:simpleType> | |
<xs:restriction base=""xs:string""> | |
<xs:maxLength value=""128"" /> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:element> | |
<xs:element name=""Description"" msprop:DataTypeName=""nvarchar"" msprop:ColumnSize=""2147483647"" minOccurs=""0""> | |
<xs:simpleType> | |
<xs:restriction base=""xs:string""> | |
<xs:maxLength value=""2147483647"" /> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:element> | |
<xs:element name=""ParentDocId"" msdata:DataType=""System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" msprop:DataTypeName=""sql_variant"" type=""xs:anyType"" minOccurs=""0"" /> | |
<xs:element name=""OwnerId"" msprop:DataTypeName=""int"" type=""xs:int"" minOccurs=""0"" /> | |
<xs:element name=""LastUpdateLoginId"" msprop:DataTypeName=""int"" type=""xs:int"" minOccurs=""0"" /> | |
<xs:element name=""DateTimeCreated"" msprop:DataTypeName=""datetime"" type=""xs:dateTime"" minOccurs=""0"" /> | |
<xs:element name=""DocHtml"" msprop:DataTypeName=""nvarchar"" msprop:ColumnSize=""2147483647"" minOccurs=""0""> | |
<xs:simpleType> | |
<xs:restriction base=""xs:string""> | |
<xs:maxLength value=""2147483647"" /> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:element> | |
<xs:element name=""RawText"" msprop:DataTypeName=""nvarchar"" msprop:ColumnSize=""2147483647"" minOccurs=""0""> | |
<xs:simpleType> | |
<xs:restriction base=""xs:string""> | |
<xs:maxLength value=""2147483647"" /> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:element> | |
<xs:element name=""AbcEventId_MLCaption_MLS1Lang"" msprop:DataTypeName=""nvarchar"" msprop:ColumnSize=""2147483647"" minOccurs=""0""> | |
<xs:simpleType> | |
<xs:restriction base=""xs:string""> | |
<xs:maxLength value=""2147483647"" /> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:element> | |
<xs:element name=""OwnerId_DisplayName"" msprop:DataTypeName=""nvarchar"" msprop:ColumnSize=""128"" minOccurs=""0""> | |
<xs:simpleType> | |
<xs:restriction base=""xs:string""> | |
<xs:maxLength value=""128"" /> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:element> | |
<xs:element name=""ApdStatusId_MLCaption_MLS1Lang"" msprop:DataTypeName=""nvarchar"" msprop:ColumnSize=""2147483647"" minOccurs=""0""> | |
<xs:simpleType> | |
<xs:restriction base=""xs:string""> | |
<xs:maxLength value=""2147483647"" /> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:element> | |
</xs:sequence> | |
</xs:complexType> | |
</xs:element> | |
</xs:choice> | |
</xs:complexType> | |
<xs:unique name=""Constraint1"" msdata:PrimaryKey=""true""> | |
<xs:selector xpath="".//row"" /> | |
<xs:field xpath=""AbcDocId"" /> | |
</xs:unique> | |
</xs:element> | |
</xs:schema> | |
"; | |
XElement xE = XElement.Parse(xml); | |
DataTable dt = new DataTable(); | |
using (XmlReader r = xE.CreateReader()) | |
{ | |
dt.ReadXmlSchema(r); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment