How do you really know if your XML document is valid? One way is to check it with an XML validator, and there are plenty out there to choose from. As we saw in Chapter 1, validators are packages that will check your XML and give you feedback. Here's a list of some of the XML validators on the Web:
To see one of these online validators at work, take a look at Figure 1-11 back in Chapter 1. There, I'm asking the XML validator from the Scholarly Technology Group to validate greeting.xml after I've added a DTD and purposely exchanged the order of the <MESSAGE> and </GREETING> tags: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE DOCUMENT [ <!ELEMENT DOCUMENT (GREETING, MESSAGE)> <!ELEMENT GREETING (#PCDATA)> <!ELEMENT MESSAGE (#PCDATA)> ]> <DOCUMENT> <GREETING> Hello From XML <MESSAGE> </GREETING> Welcome to the wild and woolly world of XML. </MESSAGE> </DOCUMENT> You can see the results in Figure 1-12 in Chapter 1; as you see there, the validator is indicating that there is a problem with these two tags. In general, then, you can use a validator to check your document. Validators can help a great deal, as you're writing long and difficult XML documents, because you can often check them at each development stage. Having gotten the <!DOCTYPE> element in place, we're ready to start creating the DTD, starting with the <!ELEMENT> element. |