Working with Microsoft XML Notepad
XML is almost, but not quite, readable by the average human. Reading simple files is almost trivial, but once the data gets nested a few layers deep, reading it can become tiresome. That's why you should have a tool for reading XML in your developer toolkit. The only problem is that some of these tools cost quite a bit for the occasional user. Microsoft has remedied this problem a little with the introduction of XML Notepad (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxml/html/xmlpaddownload.asp) This utility is free for the price of a download and does a reasonable job of reading most XML files. The current version, 1.5, is in beta as of this writing. In addition, although the Web site doesn't mention it, this version works fine with both Windows 2000 and Windows XP. The following sections provide a brief overview of this tool. We'll use this tool in several sections of the book to read XML data, so you'll want to download a copy.Opening XML FilesWhen you start XML Notepad, you'll see a blank project. Use the File >Open command to display an Open dialog box that allows you to open XML files from a local drive or from aWeb site. All you need is a filename (and path) or a URL to get started.TIP Not all XML files have an XML file extension.We've already seen one case in the book where a CONFIG file was actually an XML file in disguise. Often, you'll find that the file extension matches the customized use of the file, rather than the actual content.When in doubt, try to open a file that looks like it contains XML data to see if XML Notepad will make it easier to understand.Figure 7-1 shows the content of amovie database example I created by exporting the MovieGuide database ExistingMovies table to the Movie.XML (You'll find several XML files to view in the \Chapter 07\Sample XML Data folder of the source code, available from the Downloads section on the Apress site at http://www.apress.com/book/download.html.) Notice that the name of the elements matches the name of the table for the movie database (found in the Movie.XML file). Likewise, each of the child elements matches the name of one of the fields within the table. The right pane shows the data contained within each one of the child elements.Figure 7-1. The names of the elements are important when working with exported data in XML format.TIP If you want to use XML from your SQL Server 2000 installation, then you'll want to download the XML feature packs found athttp://msdn.microsoft.com/downloads/sample.asp?url=/MSDN-FILES/027/001/824/msdncompositedoc.xml.These feature packs add to the capabilities already found in SQL Server 2000. In addition, they help you keep your setup current by ensuring that your SQL Server 2000 installation always meets the specification requirements.Modifying Existing Data and Creating New DataYou can use XML Notepad for more than just viewing data. Creating new data for testing purposes is relatively painless once you see the exported data from an existing database. In fact, we'll create some sample data in this section for use in an application later. The following steps will get you started.