Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   Reading XML in .Net (http://www.velocityreviews.com/forums/t166389-reading-xml-in-net.html)

Dave Mc 01-11-2004 02:12 AM

Reading XML in .Net
 
First off I apologize for the length of this post.
Given the following for XML

<?xml version="1.0" encoding="Windows-1252"?>
<Product Name="Product1" xmlns:d2p1="InspectionFile">
<InspectionSite Name="Site1">
<Fiducial>
<Name>Loc1Fid1</Name>
<ModelFileName>Loc1Fid1Model.mim</ModelFileName>
<FidSearchRegion>
<X1>10</X1>
<Y1>10</Y1>
<X2>200</X2>
<Y2>200</Y2>
</FidSearchRegion>
</Fiducial>
<Fiducial>
<Name>Loc1Fid2</Name>
<ModelFileName>Loc1Fid2Model.mim</ModelFileName>
<FidSearchRegion>
<X1>500</X1>
<Y1>500</Y1>
<X2>1000</X2>
<Y2>1000</Y2>
</FidSearchRegion>
</Fiducial>
<Component>
<Name>C1</Name>
<Type>ModelFinder</Type>
<ModelFileName>C1.mim</ModelFileName>
<CompSearchRegion>
<X1>100</X1>
<Y1>200</Y1>
<X2>130</X2>
<Y2>220</Y2>
</CompSearchRegion>
<Tolerance>
<X>10</X>
<Y>10</Y>
<Q>5</Q>
</Tolerance>
</Component>
<Component>
<Name>C2</Name>
<Type>ModelFinder</Type>
<ModelFileName>C1.mim</ModelFileName>
<CompSearchRegion>
<X1>170</X1>
<Y1>200</Y1>
<X2>200</X2>
<Y2>220</Y2>
</CompSearchRegion>
<Tolerance>
<X>10</X>
<Y>10</Y>
<Q>5</Q>
</Tolerance>
</Component>
</InspectionSite>
</Product>

and the following for a schema

<?xml version="1.0" ?>
<!-- Start Schema-->
<xs:schema id="ProductFileSchema" targetNamespace="InspectionFile"
xmlns:mstns="InspectionFile"
xmlns="InspectionFile" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<!--start product-->
<xs:element name="Product" msdata:IsDataSet="true"
msdata:EnforceConstraints="False">
<xs:complexType>
<xs:sequence>
<!--start inspection site-->
<xs:element name="InspectionSite" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<!--Start Fiducial-->
<xs:element name="Fiducial" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" minOccurs="0" />
<xs:element name="ModelFileName" type="xs:string"
minOccurs="0" />
<xs:element name="FidSearchRegion">
<xs:complexType>
<xs:sequence>
<xs:element name="X1" type="xs:unsignedInt"></xs:element>
<xs:element name="Y1" type="xs:unsignedInt"></xs:element>
<xs:element name="X2" type="xs:unsignedInt"></xs:element>
<xs:element name="Y2" type="xs:unsignedInt"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!--End Fiducial-->
<!--Start Component-->
<xs:element name="Component" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" minOccurs="0" />
<xs:element name="Type" type="xs:string" minOccurs="0" />
<xs:element name="ModelFileName" type="xs:string"
minOccurs="0" />
<xs:element name="CompSearchRegion" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="X1" type="xs:unsignedInt" minOccurs="0"
/>
<xs:element name="Y1" type="xs:unsignedInt" minOccurs="0"
/>
<xs:element name="X2" type="xs:unsignedInt" minOccurs="0"
/>
<xs:element name="Y2" type="xs:unsignedInt" minOccurs="0"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Tolerance" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="X" type="xs:unsignedInt" minOccurs="0"
/>
<xs:element name="Y" type="xs:unsignedInt" minOccurs="0"
/>
<xs:element name="Q" type="xs:unsignedInt" minOccurs="0"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!--end Component-->
</xs:sequence>
<xs:attribute name="Name" type="xs:string" />
</xs:complexType>
</xs:element>
<!--end Inspection Site-->
</xs:sequence>
<xs:attribute name="Name" type="xs:string" />
</xs:complexType>
</xs:element>
<!--end product-->
</xs:schema>
<!--end schema-->

Can anyone tell me why I can't load this directly into a dataset? This
leaves me with an empty dataset

InspDataSet =new System.Data.DataSet();
InspDataSet.ReadXmlSchema("InspectionFileTest1.xsd ");
InspDataSet.ReadXml(filename);

When I connect this to a grid I get the right format for the schema
but no data. Any clues?


All times are GMT. The time now is 01:55 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.