locked
Root Element Missing RRS feed

  • Question

  • I must be missing something simple, but this has beaten me for days.

    I exported a data table from Access to XML with and XSD schema.

    When I try to import it into a dataset in VB 2013 it gives me "Missing Root Element" error when trying to ReadXmlSchema.

    So I tried adding the dataset as a datasource and using the XSD file created by Visual Studio. This succeeded in creating the Dataset, but I then get the "Missing Root Element" error when I try to import the XML data.

    So, I tried to create a XSD schema from the XML data and I am back to getting the error when I try to ReadXmlSchema.

            Dim uniEncoding As New UnicodeEncoding()
            Dim XSD As Byte() = uniEncoding.GetBytes(My.Resources.T9799PLS1XSD)
            Dim thisDataSet As New DataSet()
            Dim NewFile As New MemoryStream
    
            NewFile.Write(XSD, 0, My.Resources.T9799PLS1XSD.Length)
    
            ' Invoke the ReadXmlSchema method with the memory stream.
            thisDataSet.ReadXmlSchema(NewFile)
    and a snippet of XSD file (removed most of the elements)

    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="_FileDataSet">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="T9799PLS1" maxOccurs="unbounded" minOccurs="0">
              <xs:complexType mixed="true">
                <xs:sequence>
                  <xs:element type="xs:byte" name="FEATURE_ID" minOccurs="0"/>
                  <xs:element type="xs:string" name="fld_Feature_Name" minOccurs="0"/>
    </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    Any help is appreciated....

    Man, Im in way over my head!!!


    • Edited by John7276554 Saturday, June 7, 2014 12:27 AM removed comment
    Friday, June 6, 2014 7:08 PM

Answers

  • Try several changes:

    Dim XSD As Byte() = Encoding.UTF8.GetBytes(My.Resources.T9799PLS1XSD)
    Dim thisDataSet As New DataSet()
    Dim NewFile As New MemoryStream(XSD)
    thisDataSet.ReadXmlSchema(NewFile)



    • Edited by Viorel_MVP Friday, June 6, 2014 7:46 PM
    • Marked as answer by John7276554 Friday, June 6, 2014 7:49 PM
    Friday, June 6, 2014 7:44 PM

All replies

  • Try several changes:

    Dim XSD As Byte() = Encoding.UTF8.GetBytes(My.Resources.T9799PLS1XSD)
    Dim thisDataSet As New DataSet()
    Dim NewFile As New MemoryStream(XSD)
    thisDataSet.ReadXmlSchema(NewFile)



    • Edited by Viorel_MVP Friday, June 6, 2014 7:46 PM
    • Marked as answer by John7276554 Friday, June 6, 2014 7:49 PM
    Friday, June 6, 2014 7:44 PM
  • So many complexities... I understand the problem now that I see the solution....

    Now to get it to read the XML in.... using your solution, I got it to get past the "Missing Root Element", now it says "Value was either too large or too small for a signed byte." must have something messed up in my XSD.

    Thank you for all your help!!

    J


    Man, Im in way over my head!!!

    Friday, June 6, 2014 7:51 PM