Reading XML in .Net

Discussion in 'XML' started by Dave Mc, Jan 11, 2004.

  1. Dave Mc

    Dave Mc Guest

    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?
     
    Dave Mc, Jan 11, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wael Soliman

    ASP.NET Reading problem (reading .xls)

    Wael Soliman, Jan 3, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    4,809
    =?Utf-8?B?dmluYXk=?=
    Jan 3, 2005
  2. Replies:
    0
    Views:
    799
  3. Erik Wasser
    Replies:
    5
    Views:
    484
    Peter J. Holzer
    Mar 5, 2006
  4. mike myers
    Replies:
    0
    Views:
    259
    mike myers
    Feb 16, 2014
  5. Replies:
    5
    Views:
    95
    Chris Angelico
    May 14, 2014
Loading...

Share This Page