Getting XML Data Tools

A browser is a good tool for viewing XML, but you can't modify the XML using it. Because XML is pure text, you can use any editor like Notepad to edit it. However, Notepad isn't optimal because it doesn't display the XML structure. In addition, Notepad lacks tools for making the editing experience better. For example, if you want to add a new element, you must type the tag manually. Manual techniques often leave you open to data errors. Consequently, you need an editor that works well with XML files.

Many of the tools mentioned in this book rely on Microsoft XML Core Services (MSXML) 4.0. In addition, some of the coding examples also rely on this library. The latest version at the time of writing is Service Pack (SP) 2, which you can download at http://www.microsoft.com/ downloads/details.aspx?familyid=3144B72B-B4F2-46DA-B4B6-C5D7485F2B42 (MSXML 4.0 is approximately 5MB, so make sure you allocate enough time to download it). Both of the editors in the sections that follow rely on MSXML 4.0. However, Netpadd is perfectly happy using MSXML 5.0, which comes with Microsoft Office 2003. On the other hand, XMLwriter 2 specifically requests MSXML 4.0 every time you start it, even if you have MSXML 5.0 installed. Fortunately, you can install the two versions of MSXML side by side without any ill effects.

XML editors use a number of methods for displaying the XML file. Because presentation is very important when working with XML, you should choose an XML editor that presents the information in a way that you can understand. For example, Figure 4.2 shows the tree view editor used by many XML editors such as XML Notepad and XMLSpy. In addition, XML editors cost differing amounts based on the features they provide. Some editors are very expensive because they provide automated generation features and edit a number of file types.

FIGURE 4.2:

Many XML editors provide a tree view display that experts like.

Si SampleUala.XML - XML Notepad

1 File Edit View Insert Tools Help

piiSiB |;>.| e| M

Fid *| ♦

rlïsl &

aructure

Values

H rhefcoot

- I_J Parent

X Rrstchild

Pcrent Data

E SecoodChild

Child Data

!- [COMMENT]

Second Child Carment

^ FirstAttribüte

First Attribute Value

^ SecondAttribute

Second Attribute Vaiue

M tteit]

Here is some text.

[COMMENT]

This is the parent comment.

¡For Kelp, press Fl

One of the most popular XML editors on the market today is XMLSpy (http://www.xmlspy .com/). You can download a limited-time evaluation copy of the product from the Altova Web site. Once the evaluation period ends, you must either remove XMLSpy from your system or buy a copy. Another popular choice is XML Notepad—a free download originally provided by Microsoft. Microsoft doesn't officially support XML Notepad any longer. Consequently, you can't download it from Microsoft. One alternate download site is WebAttack at http:// www.webattack.com/get/xmlnotepad.shtml (this site has the 1.5 version). A good free option is XMLFox (http://www.xmlfox.com/). The left side of the XMLFox display is yet another version of the standard tree display—this one sports special symbols and colors. The unique feature of this product is that it uses a tabular view of the XML data, which works pretty well with some types of complex XML files, including those from eBay. All of these editors provide superior handling of XML files by including special symbols and specific methods for adding data. In addition, XMLSpy works on a number of other file types and provides task automation that you'll find helpful if you work on XML files frequently.

I chose the two XML editors presented in the sections that follow because they're simple to use and you can download them free. I'm not endorsing these editors as the only selections on the market—you should try a number of editors before you settle on one. However, because these editors provide good functionality and don't provide too many confusing features, you might want to try them as a starting point for your XML learning experience.

Make sure that you download any required security updates such as the one described in Microsoft Knowledge Base article KB832414 for MSXML 3.0 (http://www.microsoft ,com/downloads/details.aspx?FamilyID=0031ba5d-7b07-4872-b7a7-6bbd384ba8e9). You can find a list of MSXML downloads, including many security updates, at http:// www.microsoft.com/downloads/results.aspx?productID=&freetext=msxml.

Using Netpadd

Netpadd (http://www.netpadd.com/) is a freeware product that has some interesting features, but is also very simple to use. To write XML using this product, you need to type all of the information manually. There's little automation in this product, so when you create an opening tag, you must create the closing tag to go with it.

The display, shown in Figure 4.3, is very much like the display you'd see in Notepad, rather than the heavily formatted display provided by products such as XMLSpy that some newer developers find confusing. (You'll find the sample file shown in Figures 4.2 and 4.3 in the \Chapter 04\Samp1e XML folder of the source code found on the Sybex Web site.) Netpadd does provide keyword highlighting for your XML file, which makes viewing the information a lot easier. Use the Options ^ Hilite ^ XML menu options to define which file types receive highlighting.

One of the more interesting features that Netpadd provides for XML developers is multiple data views. For example, you can use the View ^ XML Tree command to display a tree view like the one shown in Figure 4.4. Other commands let you view the XML in other ways. Use the View ^ XSL Transformation command to display the information as transformed by an XSL file. This particular view is very helpful when working with eBay Web Services because you can fine-tune your XSL file without making numerous requests to the Web service.

You'll also like the special dialog boxes that Netpadd provides. For example, the View ^ Special Characters command displays the Special Characters dialog box. Select the character you want to use and click either Paste or Paste as HTML to place the symbol in your document. If you've ever wasted time looking up language codes online, you'll really like the Language Codes dialog box (displayed using the View ^ Language Codes command). Simply select the language you want to use and click Paste.

FIGURE 4.3:

Netpadd provides an easy to understand display of the XML file.

SampleData.XMI - Netpadd

0le Edit E&tfa £iew Options I

|<?j*nl rI ■> irp "1. U' encoding ' I II !'' ?> <THEROOT> <PARENT>

<FIRSTCH]LD>Parent Data</F ] FtSTCH ] LD>

<SEC0N0CH1LD F ] RSTMTR1 BUTE="First Attribute ualue" SECONDaTTK[BUTE="Secaaa ntti-ioiits ualu Child Data

< T—Second Child comment—> </SECGNDCH]LG> Here is sone text. </PliRCNT>

<1—This is the parent comment.—> </THERBBT>

'-XMI Tree

FIGURE 4.4:

View your XML files in various ways using Netpadd's View commands.

<P0RENT>

<FIRSTCH[LD>

Parent [iata

<SEC0NDCHILD F[RSTflTTR]BUTE-"FiVSt Attrihute Ualue" ...>

cnlid data

<ttcannent> Here is sane text. <ticonnent>

Using XMLwriter 2

XMLwriter 2 (http://www.xmlwriter.net/) is a try-before-you-buy product. I won't say that this product is shareware in the strictest sense because the trial period limits use to 30 days. That said, the trial period means you can download the product and try it before making a buying decision, which makes the buying decision easier.

Unlike many other XML editors on the market, XMLwriter 2 also uses a Notepad-style document display for editing as shown in Figure 4.5. This product automatically assumes you want to use color-coding for keywords. You'll also find the use of automation nice. For example, when you type an opening tag, XMLwriter 2 automatically creates a closing tag for you. Load a schema for your XML file and you'll be able to choose tags directly from the TagBar displayed on the left side of the screen. The IDE also features an XML checker. Simply right-click the document and select Validate XML File from the context menu. Any errors appear in a TODO list at the bottom of the IDE.

This product includes a number of features that the serious XML developer will need. For example, you can build projects using XMLwriter 2. Creating a project organizes the files and makes it easier to build the links you need. XMLwriter 2 comes with built-in support for all of the standard files—including XML, XSL, XSLT, HTML, XHTML, CSS, DTD, XSD, and text. In addition, you can open some types of image files, such as the GIF, JPG, and PNG files used by many Web sites. However, the files you can open aren't actually limited to these types. You can add new types to the list, so long as XMLwriter 2 can read them (which means that you can add any text-based file extension).

FIGURE 4.5:

XMLwriter 2 uses a document style editor, but provides many features found in high-end products.

FIGURE 4.5:

XMLwriter 2 uses a document style editor, but provides many features found in high-end products.

The IDE itself is fully configurable using any of the Options dialog box entries. Fortunately, the default setup is quite usable. For example, the tabbed presentation means you can see multiple versions of your XML file with ease. For example, if you want to see a tree view of your document, simply right-click the document and select View As Tree from the context menu. Figure 4.6 shows a typical example of the tree view. You can also choose a browser view for your document.

FIGURE 4.6:

Select a tree view to see the overall layout of your XML document.

FIGURE 4.6:

Select a tree view to see the overall layout of your XML document.

Was this article helpful?

0 0
Ebay PowerSeller

Ebay PowerSeller

The Definitive Guide to Becoming an eBay Powerseller guides you through the rules, giving lists of prohibited items, behaviors, and other landmines.

Get My Free Ebook


Post a comment