<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'XML file error' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'XML file error' posted on the 'VB.NET' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sun, 26 May 2013 00:25:13 -0700</pubDate>
    <lastBuildDate>Sun, 26 May 2013 00:25:13 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>XML file error</title>
      <link>http://www.programmersheaven.com/mb/VBNET/315022/315022/xml-file-error/</link>
      <description>I am trying to open an XML... the file was written by VB.Net using the dataset.WriteXML method&lt;br /&gt;
&lt;br /&gt;
When I use the ReadXML method to open it, I get the message: The data at the root level is invalid. Line 1, Position 1.&lt;br /&gt;
&lt;br /&gt;
I have open the file in IE with out any problems.&lt;br /&gt;
&lt;br /&gt;
I am not using a schema file... please let me know if you think this is why.  &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/315022/315022/xml-file-error/</guid>
      <pubDate>Tue, 13 Sep 2005 03:41:38 -0700</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: XML file error</title>
      <link>http://www.programmersheaven.com/mb/VBNET/315022/315037/re-xml-file-error/#315037</link>
      <description>I have used the DS function with the Schemea and without. What overload are you using for the ReadXML function? &lt;br /&gt;
&lt;br /&gt;
~rlc&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/315022/315037/re-xml-file-error/#315037</guid>
      <pubDate>Tue, 13 Sep 2005 06:05:04 -0700</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: XML file error</title>
      <link>http://www.programmersheaven.com/mb/VBNET/315022/315130/re-xml-file-error/#315130</link>
      <description>: I have used the DS function with the Schemea and without. What overload are you using for the ReadXML function? &lt;br /&gt;
: &lt;br /&gt;
: ~rlc&lt;br /&gt;
: &lt;br /&gt;
dim ds as new dataset&lt;br /&gt;
dim fs as IO.StreamReader("FileName.XML")&lt;br /&gt;
dim xr as XML.XmlTextReader(fs)&lt;br /&gt;
ds.ReadXml(xr)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/315022/315130/re-xml-file-error/#315130</guid>
      <pubDate>Tue, 13 Sep 2005 18:38:05 -0700</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: XML file error</title>
      <link>http://www.programmersheaven.com/mb/VBNET/315022/315132/re-xml-file-error/#315132</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by rlc at  2005-9-13 18:51:28&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
I think the problem is you are not using "NEW" the create instances of the  test reader and stream. If you just do...&lt;br /&gt;
&lt;pre class="sourcecode"&gt;ds.readxml(&amp;lt;filename&amp;gt;)&lt;/pre&gt;&lt;br /&gt;
It will work but you may lose some of the formatting.. I am not sure the exact difference. I have a function that loads tables in a DB during install using the reader method I will paste a relvant snip below...&lt;br /&gt;
&lt;br /&gt;
~rlc&lt;br /&gt;
&lt;br /&gt;
EDIT: P.S. this method assumes the XML file has the schema&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
        ' load each xml file into the database
        Try

            Dim lSqlConnection As SqlClient.SqlConnection = New SqlClient.SqlConnection(m_ConnectString)
            Dim lCommand As SqlClient.SqlCommand
            Dim lBuilder As SqlClient.SqlCommandBuilder
            Dim lDataAdapter As SqlClient.SqlDataAdapter
            Dim lDataSet As DataSet
            Dim lCurrFileName As String
            Dim lCurrTableName As String
            Dim lXmlReader As Xml.XmlTextReader

            For Each lCurrFileName In Directory.GetFiles(lXmlPath, "*.xml")


                lCurrTableName = Path.GetFileNameWithoutExtension(lCurrFileName)
                If Not m_IsUpdate OrElse Array.IndexOf(m_UpdateData, lCurrTableName) &amp;lt;&amp;gt; -1 Then
                    ' do this table
                    WriteEvent("Loading data from " &amp;amp; lCurrFileName)
                    lCommand = New SqlClient.SqlCommand("SELECT * FROM [" &amp;amp; lCurrTableName &amp;amp; "]", lSqlConnection)
                    lDataAdapter = New SqlClient.SqlDataAdapter(lCommand)
                    lBuilder = New SqlClient.SqlCommandBuilder(lDataAdapter)
                    lDataSet = New DataSet(lCurrTableName)
                    lXmlReader = New Xml.XmlTextReader(lCurrFileName)
                    lDataSet.ReadXml(lXmlReader, XmlReadMode.ReadSchema)
                    lDataAdapter.Update(lDataSet)
                    lXmlReader.Close()
                End If
            Next

            lSqlConnection.Close()

        Catch ex As SqlClient.SqlException
            WriteEvent("Error inserting data: " &amp;amp; ex.Message)
        End Try
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: : I have used the DS function with the Schemea and without. What overload are you using for the ReadXML function? &lt;br /&gt;
: : &lt;br /&gt;
: : ~rlc&lt;br /&gt;
: : &lt;br /&gt;
: dim ds as new dataset&lt;br /&gt;
: dim fs as IO.StreamReader("FileName.XML")&lt;br /&gt;
: dim xr as XML.XmlTextReader(fs)&lt;br /&gt;
: ds.ReadXml(xr)&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/315022/315132/re-xml-file-error/#315132</guid>
      <pubDate>Tue, 13 Sep 2005 18:50:09 -0700</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: XML file error</title>
      <link>http://www.programmersheaven.com/mb/VBNET/315022/315175/re-xml-file-error/#315175</link>
      <description>: &lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by rlc at  2005-9-13 18:51:28&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: I think the problem is you are not using "NEW" the create instances of the  test reader and stream. If you just do...&lt;br /&gt;
: &lt;pre class="sourcecode"&gt;ds.readxml(&amp;lt;filename&amp;gt;)&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I was using the "new" instance on the declaration... sorry I didn't include that in my previous message... but the above worked perfect, and is a much simpler method than having to use my own file stream and textreader... thanks for the help&lt;br /&gt;
&lt;br /&gt;
I will look closer at you code as it looks like something I may need...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/315022/315175/re-xml-file-error/#315175</guid>
      <pubDate>Wed, 14 Sep 2005 05:23:23 -0700</pubDate>
      <category>VB.NET</category>
    </item>
  </channel>
</rss>