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


0
Tony
3/28/2007 10:08:10 PM
dotnet.xml 7266 articles. 0 followers. Follow

7 Replies
669 Views

Similar Articles

[PageSpeed] 50

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()



0
3/29/2007 5:47:54 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

"Latish Sehgal" <latish.sehgal@gmail.com> wrote in message 
news:1175190474.117544.50560@n59g2000hsh.googlegroups.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()
>
>
> 


0
Tony
3/29/2007 7:02:23 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?

0
3/29/2007 7:33:26 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

"Latish Sehgal" <latish.sehgal@gmail.com> wrote in message 
news:1175196806.654090.134790@p15g2000hsd.googlegroups.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?
> 


0
Tony
3/29/2007 7:51:14 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.

0
3/29/2007 8:55:41 PM
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" <latish.sehgal@gmail.com> wrote in message 
news:1175201741.491524.311960@y66g2000hsf.googlegroups.com...
> It should, but it probably depends on your xml.
> Check out
> http://samples.gotdotnet.com/quickstart/howto/doc/Xml/DataSetMapXMLData.aspx
> for an example.
> 


0
Tony
3/30/2007 10:46:50 AM
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.

0
3/30/2007 8:20:33 PM
Reply:

Similar Artilces: