473,399 Members | 2,774 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,399 software developers and data experts.

Trying to read XML file into dataset

Hello.

Developing a web site in VS2005, SP1, VB, .NET 2.0, ASP.NET 2.0 on XP Pro,
SP2.

I eventually want to use a gridview table to view xml data, but right now i
can't seem to get my xml data into a dataset so that i can use it.

I have an XML file and can open it in IE. There is no XSD or XSL file to go
with it.
I can't seem to get the XML data into a dataset. I tried using the
following code, but it just does nothing. It doesn't give an error. It
just executes the code and does nothing.

Dim dataSet As DataSet = New DataSet
dataSet.ReadXml("c:\Trips.xml", XmlReadMode.Auto)

I tried the XmlReadMode.InferSchema, XmlReadMode.InferTypedSchema and
XmlReadMode.ReadSchema options.

Any help would be gratefully appreciated.

Thanks,
Tony
Mar 28 '07 #1
7 15099
Your code should be
dataSet.ReadXml(@"c:\Trips.xml", XmlReadMode.Auto)
to account for the slash in the path.

Besides this, the same code works for me. I tested by printing
dataSet.GetXml()

Mar 29 '07 #2
Hello Latish.

My program will not compile with the "@" in there. It says "Character is
not valid".

If i put the "@" inside the quotes like "@C:\Trips.xml", when it runs, it
gives a System.NotSupportedException {"The given path's format is not
supported."}.

Thanks,
Tony

"Latish Sehgal" <la***********@gmail.comwrote in message
news:11*********************@n59g2000hsh.googlegro ups.com...
Your code should be
dataSet.ReadXml(@"c:\Trips.xml", XmlReadMode.Auto)
to account for the slash in the path.

Besides this, the same code works for me. I tested by printing
dataSet.GetXml()

Mar 29 '07 #3
Sorry about that. Its a C# thing, i didn't realize it.

Have you tried copying the value of dataSet.GetXml() to a string and
checking the value?

Mar 29 '07 #4
Well. Sure enough. The xml data is there. Maybe i need to do something
with the dataset after the ReadXml statement.

Maybe i'm misinterpreting the ReadXML function. Is it supposed to create a
table(s) in the dataset based on what it reads from the xml file?

Thanks,
Tony

"Latish Sehgal" <la***********@gmail.comwrote in message
news:11**********************@p15g2000hsd.googlegr oups.com...
Sorry about that. Its a C# thing, i didn't realize it.

Have you tried copying the value of dataSet.GetXml() to a string and
checking the value?

Mar 29 '07 #5
It should, but it probably depends on your xml.
Check out
http://samples.gotdotnet.com/quickst...apXMLData.aspx
for an example.

Mar 29 '07 #6
Hello Latish.

I tried that sample. It doesn't give any errors, but it doesn't do
anything. It just executes the code.

Also, what is "Console.WriteLine" supposed to do? Where does it write the
output?

I looked in the Output, Immediate, Command and every other window. I can't
find the output.

Thanks,
Tony

"Latish Sehgal" <la***********@gmail.comwrote in message
news:11**********************@y66g2000hsf.googlegr oups.com...
It should, but it probably depends on your xml.
Check out
http://samples.gotdotnet.com/quickst...apXMLData.aspx
for an example.

Mar 30 '07 #7
Console.WriteLine would work in console apps, you can change it to
Debug.Write() or something for your debugging.
I just pointed out that example so that you can compare it with your
code and see if the tables can be created from the xml in that
example.

Probably you should post your xml here also.

Mar 30 '07 #8

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

Similar topics

1
by: Sal | last post by:
Hello all, I am working on a project with the following characteristics: 1. Load data from a SQL server table to an xml file 2. Read the xml file into a dataset. 3. Load data from the...
4
by: jaime | last post by:
1 I load a text file into a dataset, after doing a bit of work.. 2 Now I have a dataset full of data that I like to transfer to a data base 3 My problem is that if the rowstate of the row is set to...
0
by: Eric Paul | last post by:
I have been in search of a better way to handle bulk inserts and updates into SQL 2000 using c# and while I have found a few different ways to accomplish this I was wondering what is considered to...
0
by: Peter | last post by:
I am having a problem reading an Excel file that is XML based. The directory I am reading contains Excel files that can be of two types. Either generic Microsoft based or XML based. I am reading...
15
by: ruca | last post by:
Hi, Can I read a .TXT File to a DataSet? How can I do that? I want to read his lines to a DropDownList. This lines are the names of employees that I export from an application that I have. I...
2
by: Mits | last post by:
I am using following connection string to get data from a .csv file using vb.net strConnstr = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + System.IO.Path.GetDirectoryName(sFileName) +...
0
by: ntuyen01 | last post by:
Hi All, I try to read the data from the excel, but I ran into this problem I have two excel files. file one.xls data inside like this: 1234 1234 1234 1234 abc-123 ...
1
by: unsichtbar | last post by:
Sorry, but I'm pretty new to .NET/XML etc... I have the current code which I'm trying to output dynamically so it can be read into a flash file. The only issue is, it doesn't seem to actually do...
1
by: Laila2008 | last post by:
Hi, I'm writing a String containing XML data to my browser. The XML data is well formed and the page opens up correctly but when I try to read this data from another page I get the following error:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.