(A prolific PowerShell poster suggested I come over here....)
I have a schema but it doesn't import correctly into a DataSet with the expected table names.
There is more but I think if this gets solved the rest will, what am I doing wrong with the table names?
My PowerShell code (actually, the same thing happens with c#):
clear-host $dsXml = new-object "System.Data.DataSet" $dsXml.ReadXmlSchema("C:\temp\xml\mySchemaTest.xsd") $dsXml.ReadXml("c:\temp\xml\myXmlTest.xml", 'ReadSchema') Write-Host "Table names in dataset" Write-Host "======================" foreach ($table in $dsXml.Tables) { Write-Host $table.TableName }
The schema (tested as valid)
<?xml version="1.0" encoding="utf-8"?><xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="products"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="books"><xs:complexType><xs:sequence><xs:element minOccurs="0" maxOccurs="unbounded" name="item"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="title" type="xs:string" /><xs:element minOccurs="0" name="pageCount" type="xs:string" /><xs:element minOccurs="0" name="price" type="xs:integer" /></xs:sequence></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element><xs:element minOccurs="0" name="fruits"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="item"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="type" type="xs:string" /><xs:element minOccurs="0" name="color" type="xs:string" /><xs:element minOccurs="0" name="price" type="xs:string" /></xs:sequence></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element></xs:schema>
result (I only expected 2 tables, all my data is actually in the table "items" in an all messed up way):
ReadSchema Table names in dataset ====================== books item fruits