Results 1 to 4 of 4

Thread: How read XML schema with Primary Key?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2008
    Posts
    21

    How read XML schema with Primary Key?

    Hello.

    I import a XML to a Dataset and works fine, import XML with Schema and fine to, but for any estrange reason the primary key that is in the XSD don't appears in the Dataset.

    The XML and XSD are generated from a access 2003 table, right button and export.

    This is my code
    Code:
    str1 = "C:\tbl1.xml"
    str2 = "C:\tbl1.xsd"
    ds.ReadXml(str2, XmlReadMode.ReadSchema)
    ds.ReadXml(str1)
    Any help?

    Thanks.

  2. #2
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    407

    Re: How read XML schema with Primary Key?

    Can you provide the files tbl1.xml and tbl1.xsd? Whats Ds? Cna you provide the complete function code?
    My Websites
    SharpMP3 - MP3 Design Articles www.sharpmp3.com
    Yobbers - Job Search www.yobbers.com
    Lets Trend - Methods For Riding Stock Trends www.letstrend.com

  3. #3
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: How read XML schema with Primary Key?

    ReadXml(fileName, mode) attempts to read an inline schema from an xml file. Have you tried using the ReadXmlSchema like:

    Code:
            Dim str1 = "C:\tbl1.xml"
            Dim str2 = "C:\tbl1.xsd"
            ds.ReadXmlSchema(str2)
            ds.ReadXml(str1)

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2008
    Posts
    21

    Re: How read XML schema with Primary Key?

    Good Morning.

    ds is a dataset who is defined previously.

    This is the xsd:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:od="urn:schemas-microsoft-com:officedata">
    <xsd:element name="dataroot">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="tbl1" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute name="generated" type="xsd:dateTime"/>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="tbl1">
    <xsd:annotation>
    <xsd:appinfo>
    <od:index index-name="PrimaryKey" index-key="id " primary="yes" unique="yes" clustered="no"/>
    <od:index index-name="id" index-key="id " primary="no" unique="no" clustered="no"/>
    </xsd:appinfo>
    </xsd:annotation>
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="id" minOccurs="1" od:jetType="autonumber" od:sqlSType="int" od:autoUnique="yes" od:nonNullable="yes" type="xsd:int"/>
    <xsd:element name="name" minOccurs="0" od:jetType="text" od:sqlSType="nvarchar">
    <xsd:simpleType>
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="50"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    The function don't have more code.

    For the sugerency about use reaXML without optional parameters, don't works

    I can add the primary key with code using:
    Code:
    DataColumn primarykey = ds.Tables["tbl1"].Columns["id"];
    but is more right and clean if catch it from the XSD.

    I continue searching in the web ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width