Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / March 2007

Tip: Looking for answers? Try searching our database.

Trying to read XML file into dataset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tony Girgenti - 28 Mar 2007 23:08 GMT
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
Latish Sehgal - 29 Mar 2007 18:47 GMT
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()
Tony Girgenti - 29 Mar 2007 20:02 GMT
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

> 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()
Latish Sehgal - 29 Mar 2007 20:33 GMT
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?
Tony Girgenti - 29 Mar 2007 20:51 GMT
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

> 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?
Latish Sehgal - 29 Mar 2007 21:55 GMT
It should, but it probably depends on your xml.
Check out
http://samples.gotdotnet.com/quickstart/howto/doc/Xml/DataSetMapXMLData.aspx
for an example.
Tony Girgenti - 30 Mar 2007 11:46 GMT
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

> It should, but it probably depends on your xml.
> Check out
> http://samples.gotdotnet.com/quickstart/howto/doc/Xml/DataSetMapXMLData.aspx
> for an example.
Latish Sehgal - 30 Mar 2007 21:20 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.