Q&A
| Q1: | You showed me a couple ways to load XML documents. Which is the best way to load an XML document? |
A1: | The best way might not be the easiest way. Using the XmlDocument class with DOM gives you great flexibility, but at the cost of resources. Using the XmlTextReader is super fast and efficient, but it's a forward-only stream, so you might find it limited. Loading an XML document into a DataSet is easy too, but you must be familiar with navigating tables and rows in a DataSet to work effectively with the XML document. So, the short answer is that there's no single best way; there's only a best way based on what you need to do with the data and what syntax you are familiar with. |
| Q2: | Why go through all the trouble of creating schemas in the designer when I can just use the WriteXmlSchema method of the DataSet class? |
A2: | Using the WriteXmlSchema method is an easy way to get a schema from tables in a database, but it might not build the schema correctly based on the hierarchy you're looking for. If you build a few more schemas with the Schema Designer, you'll realize it's as easy as creating a table in SQL Server and calling WriteXmlSchema. |
| Q3: | You aren't showing me how to do any of this in ASP.NET. Why? |
A3: | All the code you wrote today can be cut and pasted directly into an ASP.NET application and run without modification. The DataGrid in Windows Forms correctly displays the hierarchy of the data, but the Web Forms DataGrid doesn't, so I wanted you to get an idea of what the data looks like in real life, not in the flat grid on a Web page. It's very easy to see how to write data back to an XML file using the DataGrid. This is still possible in ASP.NET, but not with the grid control. |
| Q4: | I'm hungry for more XML. Where do I go next? |
A4: | If you're a hardcore XML developer, a must-have book on the shelf is XML for ASP.NET, by Dan Wahlin. That book covers pretty much everything you'd ever need to know about XML and .NET. I highly recommend it.Online, the MSDN XML Developer Center is jam-packed with XML programming information. You can find it at the following URL:http://www.msdn.microsoft.com/library/default.asp?url=/nhp/default.asp?contentid=28000438Also on Microsoft.com is the XML series of online seminars. I recommend viewing the seminar about transforming XML with XSLT in .NET, which is important but beyond the scope of this book:http://support.microsoft.com/default.aspx?scid=kb;en-us;q326069If you need some other great examples of using XSLT to transform XML, check out the XSLT Stylesheet Library at http://www.xmlpitstop.com. There are tons of great examples of transforming XML with XSLT in .NET. |
• Table of Contents
• Index
Sams Teach Yourself Visual Studio® .NET 2003 in 21 Days
By
Jason Beres
Publisher
: Sams Publishing
Pub Date
: January 14, 2003
ISBN
: 0-672-32421-0
Pages
: 696
Sams Teach Yourself Visual Studio .NET in 21 Days will help developers that are new to application development and experienced developers understand how to use the .NET Framework and Visual Studio .NET to rapidly develop any type of computer application. The Visual Studio .NET development environment is the most comprehensive developer tool ever created, putting that together with the .NET Frameworks' Class Libraries, the developer has everything he or she needs to get up-to-speed on Microsoft's latest revolution in application development. This book will guide the developer through using the VS .NET IDE, the Visual Basic .NET and C# language, and the supporting tools available from Microsoft to create Windows and Web-based applications. The market is full of books that pretty much say the same thing, which is already available in the help files, the author of this book has written and deployed over a dozen successful applications using Visual Studio .NET and the .NET Framework. All of his expertise and experience is used to give you the most comprehensive title on using Visual Studio .NET.