all groups > dotnet xml > march 2007 >
You're in the

dotnet xml

group:

Trying to read XML file into dataset


Trying to read XML file into dataset Tony Girgenti
3/28/2007 6:08:10 PM
dotnet xml:
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

Re: Trying to read XML file into dataset Latish Sehgal
3/29/2007 10:47:54 AM
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()


Re: Trying to read XML file into dataset Latish Sehgal
3/29/2007 12:33:26 PM
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?
Re: Trying to read XML file into dataset Latish Sehgal
3/29/2007 1:55:41 PM
It should, but it probably depends on your xml.
Check out
http://samples.gotdotnet.com/quickstart/howto/doc/Xml/DataSetMapXMLData.aspx
for an example.
Re: Trying to read XML file into dataset Tony Girgenti
3/29/2007 3:02:23 PM
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

[quoted text, click to view]

Re: Trying to read XML file into dataset Tony Girgenti
3/29/2007 3:51:14 PM
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

[quoted text, click to view]

Re: Trying to read XML file into dataset Tony Girgenti
3/30/2007 12:00:00 AM
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

[quoted text, click to view]

Re: Trying to read XML file into dataset Latish Sehgal
3/30/2007 1:20:33 PM
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.
AddThis Social Bookmark Button