473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Baffling READXML problem

I have a well-formed XML file that I am trying to load into a dataset
using the ReadXML method. It keeps telling me that "there are multiple
root elements". I can view the data using XML Designer in Visual
Studio 2003 without any problems and the schema and file have been
validated using several different tools. I even successfully generated
a typed dataset with Visual Studio 2003 by importing the XML into my
project. I'm baffled, does anyone have any thoughts?

This is the latest version. I've tried it using various xmlReadModes
and without the ReadXmlSchema call but I get the same exception every
time.

Dim y As New DataSet

Dim xmlPath as String = "..\01.xml"

Dim xmlFileStream As New FileStream(xmlPath, FileMode.Open)

Dim xmlTextReader As New XmlTextReader(xmlFileStream)

Try
y.ReadXmlSchema("..\01.xsd")
y.ReadXml(xmlFileStream, XmlReadMode.IgnoreSchema)

Catch ex As Exception
Throw ex

End Try

Nov 12 '05 #1
2 1791
HI,

You need to add DataTable for the DataSet and Columns for the DataTable the same time.

MSDN site has really good topic with sample code showing you how to accomplish this:

http://msdn.microsoft.com/library/en...asp?frame=true

-- Yingzi

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
--------------------
From: "bf*****@comcast.net" <bf*****@comcast.net>
Newsgroups: microsoft.public.dotnet.xml
Subject: Baffling READXML problem
Date: 19 Oct 2005 09:39:27 -0700
Organization: http://groups.google.com
Lines: 29
Message-ID: <11**********************@g43g2000cwa.googlegroups .com>
NNTP-Posting-Host: 146.243.4.157
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1129739980 7411 127.0.0.1 (19 Oct 2005 16:39:40 GMT)
X-Complaints-To: gr**********@google.com
NNTP-Posting-Date: Wed, 19 Oct 2005 16:39:40 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.0 proxysv03.jud.state.ma.us:3128 (Squid/2.4.STABLE6)
Complaints-To: gr**********@google.com
Injection-Info: g43g2000cwa.googlegroups.com; posting-host=146.243.4.157;
posting-account=KjtniQ0AAAAnunjTbEKn-UFEdcuIddxr
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfee d00.sul.t-online.de!t-online.de!news.glorb.com!postnews.google.com! g43g2000cwa.googlegroups.com!not-for-mailXref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:8985
X-Tomcat-NG: microsoft.public.dotnet.xml

I have a well-formed XML file that I am trying to load into a dataset
using the ReadXML method. It keeps telling me that "there are multiple
root elements". I can view the data using XML Designer in Visual
Studio 2003 without any problems and the schema and file have been
validated using several different tools. I even successfully generated
a typed dataset with Visual Studio 2003 by importing the XML into my
project. I'm baffled, does anyone have any thoughts?

This is the latest version. I've tried it using various xmlReadModes
and without the ReadXmlSchema call but I get the same exception every
time.

Dim y As New DataSet

Dim xmlPath as String = "..\01.xml"

Dim xmlFileStream As New FileStream(xmlPath, FileMode.Open)

Dim xmlTextReader As New XmlTextReader(xmlFileStream)

Try
y.ReadXmlSchema("..\01.xsd")
y.ReadXml(xmlFileStream, XmlReadMode.IgnoreSchema)

Catch ex As Exception
Throw ex

End Try

Nov 12 '05 #2
Thanks but that example is in the regular documentation. The only
reason the data table and columns were created was in order to write
out an xml file so it could subsequently read it back in.
Additionally, the "Original" data set is not a typed dataset. The
example doesn't really address my problem, i.e. I don't know the size
and shape of the XML, (that's why I'm reading the XML schema) and I
want to place it in a typed dataset.

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: TimS | last post by:
I am getting a baffling File not found error (0x800A0035). I am writing asp on a windows 2000 server. I build a path and filename from several fields in a jet database using SQL commands, like...
11
by: DraguVaso | last post by:
Hi, I should use XML to synchronize the data from different (VB.NET) applications, and I was just wondering which Overloads of these functions ( ReadXmlSchema, ReadXml and WriteXml) goes the...
1
by: Jeffrey A. Voigt | last post by:
I'm having trouble loading some xml data into a dataset via the ReadXML call. I'm loading into the dataset an xml schema prior to the ReadXML call. I see that there IS in fact, 3 records that...
1
by: CB | last post by:
Using C# in .Net 2003, DataSet.ReadXml fails when a percentage (%) sign is in the filename followed by 2 hex characters. Seems that the % sign is likely encoding the following 2 hex characters. ...
12
by: Mike | last post by:
I have posted this before, but no one responds, so here it goes again. I think my question is intimidating people and I have no idea why?!? This is not a new concept. You can do this with other...
2
by: Double Echo | last post by:
Hi, Forgive me if I ask a dumb question, I'm new to classes and object programming with PHP, and cannot figure out what the problem is with this class. Maybe I have overlooked something but...
1
by: Mac | last post by:
I'm trying to validate input from an xml source to a dataset in dotnet2.0. As far as I can see, type errors correctly cause an exception, but values that are the correct type but do not satisify...
1
by: Angel \Java\ Lopez | last post by:
Hi people! I'm running a Visual Studio 2005, Professional, on Windows XP Professional. I've found a little big problem, reading a DataSet. If I try: ds.ReadXml("c:\data.xml") it raises...
2
by: ERingmae | last post by:
Hi, The environment is .NET 2.0, the language is C# and the problem is reading XSD file with xs:redefine section correctly to a XMLDataDocument.DataSet. What I am trying to do: I am trying...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.